When I plot the loss function of my code I get a nice loss plot.
If I want to plot the 1-hist.history['loss']
, how can I do it?
Part of my code:
model = Sequential([
Dense(32, activation='relu', input_shape=(2,)),
Dense(32, activation='relu'),
Dense(1, activation='relu'), ])
model.compile(optimizer='sgd',
loss='mean_squared_error')
hist = model.fit(X_train, Y_train,
batch_size=32, epochs=100,
validation_data=(X_val, Y_val))
A = model.evaluate(X_test, Y_test)[1]
print(A)
plt.plot(hist.history['loss'])
plt.plot(hist.history['val_loss'])
plt.title('Model loss')
plt.ylabel('Loss')
plt.xlabel('Epoch')
plt.legend(['Train', 'Val'], loc='upper right')
plt.savefig("loss.png") # Save the plot of loss function
plt.clf()
In this part of the code: plt.plot(hist.history['loss'])
I want to change it to the number that complete to 1.
Is there a way to do that?
Something to try in case hist
is a pandas dataframe:
complete_to_one = 1 - hist.history['loss'])
plt.plot(complete_to_one)