<jupyter_start><jupyter_text>Data loading<jupyter_code>BM_paths = np.load('BM_paths.npy')
number_of_samples = BM_paths.shape[0]
"""
BM1001 = np.zeros([number_of_samples, 1001])
for i in range(number_of_samples):
    for j in range(5001):
        if j%5==0:
            BM1001[i][int(j/5)] = BM_paths[i][j]
BM_paths = BM1001
"""
print(BM_paths.shape)
output = np.load('output.npy')
T=1<jupyter_output><empty_output><jupyter_text>Hyperparameters<jupyter_code># Parameters grid
param_grid = {'deg_of_sig': [2,3,4,5,6], 'number_of_segment': [4],
'learning_rate': [0.001]}
Param = list(ParameterGrid(param_grid))
# Parameters
training_iters = 8000000
batch_size = 1024
display_step = 1
# Network Parameters
n_input = 1 # 
n_steps = np.shape(BM_paths)[1] # timesteps
n_hidden = 64 # hidden layer num of features
n_classes = 1 # the dim of the solution to SDE

Y = output
error_tol = 0.001/512

test_len = 200 #int(np.shape(BM_paths)[0]*0.1)
sig_comp_time = []
test_result = []
test_time = []<jupyter_output><empty_output><jupyter_text>train RNN with different feature sets<jupyter_code>for i in range(np.size(Param)):
    start = time.time()
    # Raw data feature set generator
    if Param[i]['deg_of_sig']==1:
        n_input = 1
        X_raw = BM_paths.reshape(-1, BM_paths.shape[1], n_input)
        print(X_raw.shape)
        model3 = Model( Param[i]['learning_rate'], training_iters, batch_size, display_step, n_input, X_raw.shape[1], n_hidden, n_classes, Param[i]['deg_of_sig'], X_raw, Y)
    # Folded raw data feature set generator
    elif Param[i]['deg_of_sig']==0:
        n_input = int(BM_paths.shape[1]/Param[i]['number_of_segment'])
        X_raw = np.zeros([BM_paths.shape[0], n_input * Param[i]['number_of_segment']])
        for j in range(BM_paths.shape[0]):
            X_raw[j] = BM_paths[j, :n_input * Param[i]['number_of_segment']]
        X_raw = X_raw.reshape(BM_paths.shape[0], Param[i]['number_of_segment'], n_input)
        elapsed = time.time()-start
        sig_comp_time.append(elapsed)
        model3 = Model( Param[i]['learning_rate'], training_iters, batch_size, display_step, n_input, Param[i]['number_of_segment'], n_hidden, n_classes, Param[i]['deg_of_sig'], X_raw, Y)
    # Logsig feature set generator
    else:
        X_logsig_start = ComputeMultiLevelLogsig1dBM(BM_paths, Param[i]['number_of_segment'], Param[i]['deg_of_sig'], T)
        n_input = np.shape(X_logsig_start)[2]
        elapsed = time.time()-start
        sig_comp_time.append(elapsed)
        model3 = Model( Param[i]['learning_rate'], training_iters, batch_size, display_step, n_input, Param[i]['number_of_segment'], n_hidden, n_classes, Param[i]['deg_of_sig'], X_logsig_start, Y)


    # build and train model
    fixed_error_result_model3 = model3.BuildModelKeras(test_len, error_tol)
    

    print("Time = " + str(time.time()-start))
    print("Testing loss = " + str(fixed_error_result_model3['Loss']))
    # model3.KerasPredict()
    test_result.append(fixed_error_result_model3 ['Loss'])
    test_time.append(fixed_error_result_model3 ['Time'])
    
    
    np.save('error_tol'+str(error_tol)+'deg_logsig'+str(Param[i]['deg_of_sig'])+'_test_result', test_result)
    np.save('error_tol'+str(error_tol)+'deg_logsig'+str(Param[i]['deg_of_sig'])+'_test_time', test_time)
    np.save('error_tol'+str(error_tol)+'deg_logsig'+str(Param[i]['deg_of_sig'])+'_sig_comp_time', elapsed)
print(test_time)
print(test_result)
print(sig_comp_time)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15087820328246473, 'fraction_numerical': 0.024762453210480852, 'mean_word_length': 5.126984126984127, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '629383', 'license': 'Apache-2.0', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1309, 'n_words': 211, 'path': 'sde_learning/SDE_learning_example.ipynb', 'repo_name': 'steveliao93/learn_sde', 'size': '3473'}