I’m currently using Keras to make a prediction model. It takes in two time series and outputs a number between 0 and 1. Currently, I am getting very low accuracy as the model is only considered “correct” if it gets the exact number. For example, the correct number is 0.34, it would be considered incorrect if it predicted 0.35. I want to be able to consider all numbers within a range to be correct, for example: within 0.05 of the true value. Another option may be to round, but I have the problem of it outputting 6 decimal places.
- How can I consider all numbers within a range to be “correct” for the accuracy?
- How can I round the output of the CNN?
Here is my CNN code:
def networkModel():
model = tf.keras.Sequential([
tf.keras.layers.Conv2D(filters = 16, kernel_size=(2, 2), activation='relu',padding='same'),
tf.keras.layers.Conv2D(filters = 9, kernel_size=(2, 2), activation='relu',padding='same'),
tf.keras.layers.MaxPooling2D(pool_size=(2, 2)),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(256, activation='relu'),
tf.keras.layers.Dense(1, activation='sigmoid')
])
model.compile(optimizer='adam',
loss = tf.keras.losses.BinaryCrossentropy(),
metrics=['accuracy'])
return model
Teresa Wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.