Example #1
0
def model_loss(target_y, predicted_y):
    return losses.esr_loss(target_y, predicted_y,
                           losses.pre_emphasis_filter) + losses.dc_loss(
                               target_y, predicted_y)
Example #2
0
# %%
fs = 1.0 / IN_train[idx, 0, -1]
freqs, pred_fft = plot_fft(predictions, fs)
freqs, target_fft = plot_fft(OUT_train[idx].flatten(), fs)

# Plot the predictions along with to the test data
plt.clf()
plt.title('Training data predicted vs actual values')
plt.semilogx(freqs, target_fft, 'b', label='Actual')
plt.semilogx(freqs, pred_fft, 'r--', label='Predicted')
plt.legend()
plt.xlim(50, 20000)
plt.ylim(-5)
plt.xlabel('Frequency [Hz]')
plt.ylabel('Magnitude [dB]')

# %%
start = 5500
end = 7000
plt.plot(clean_data[idx][start:end], hyst_data[idx][start:end])
plt.plot(clean_data[idx][start:end], predictions[start:end], '--')

# %%
print(losses.esr_loss(OUT_train, model.model.predict(IN_train)))

# %%
model.save_model(model_file)
model.save_history(model_hist)

# %%