<jupyter_start><jupyter_text>Model<jupyter_code># layers
layer_size = [20, 40, 60, 100, 200]
layer_type = ['tanh', 'relu', 'tanh', 'tanh', 'tanh']

# check that we didn't mess this up
assert len(layer_size) == len(layer_type)

# gaussian noise regularization
noise_level = .1
model = Sequential() ## initial feed forward model 

# add the input layer
model.add(Dense(x_train.shape[1], 
                activation='linear', 
                input_dim=x_train.shape[1]))

for idx, size in enumerate(layer_size):
    model.add(Dense(size, 
                    activation=layer_type[idx])) #, kernel_regularizer=keras.regularizers.l2(l=0.0001)
    #model.add(GaussianNoise(noise_level))
    
# add the output layer
model.add(Dense(y_train.shape[1], 
                activation='linear'))

opt = keras.optimizers.Adam(learning_rate=0.01)
    
model.compile(optimizer=opt, loss='mean_squared_error') ## setup the optimizer and loss function
model.summary()
n_epochs = 100
start = time.time()
hist = model.fit(x=x_train, y=y_train, 
                validation_data= (x_val, y_val),
                 batch_size = 128,
                 shuffle = 'true',
                 epochs = n_epochs,
                 verbose = 'false',
                 callbacks = [plot_losses])
end = time.time()
print('Time to train model: ' + str((end - start)/60) + ' minutes')<jupyter_output><empty_output><jupyter_text>Eval Model<jupyter_code>fig, axs = plt.subplots(1, np.shape(y_val)[1], figsize=(16, 6))
preds = model.predict(X_scaled)
errs = np.sqrt(np.mean((Y_scaled - preds)**2, axis=1))

for idx in range(np.shape(y_val)[1]):
    axs[idx].hexbin(Y_scaled[:,idx], errs, cmap = 'bone_r')
    #axs[idx].set_xlabel(y_labels[idx])
    axs[idx].set_ylabel('errs')
fig.tight_layout()
fig.savefig('rms_model_errs_corr.png')
fig, axs = plt.subplots(np.shape(y_val)[1], np.shape(x_val)[1], figsize=(18, 8))
for idx in range(np.shape(Y_scaled)[1]):
    for jdx in range(np.shape(X_scaled)[1]):
        axs[idx, jdx].hexbin(settings[:,jdx], Y_vals[:,idx], cmap = 'bone_r')
        axs[idx, jdx].set_xlabel(labels[jdx])
        axs[idx, jdx].set_ylabel(y_labels[idx])
        axs[idx, jdx].ticklabel_format(axis='x', style='sci')
fig.tight_layout()
fig.savefig('srw_correlations.png')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15971917507678807, 'fraction_numerical': 0.02106186924089513, 'mean_word_length': 3.7899159663865545, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '516593', 'license': 'Apache-2.0', 'n_tokens_mistral': 898, 'n_tokens_neox': 848, 'n_words': 149, 'path': 'MachineLearning/SRW/rms_inverse_model.ipynb', 'repo_name': 'radiasoft/rslight', 'size': '2279'}