I have the following dataset:
input_train = [[[0], [1], [1], [0], [0], [0], [0], [1], [0], [1]]]
output_train = [[0, 1, 2, 2, 2, 2, 2, 3, 3, 4]]
As you can see, the value in output_train[t] (t in range 0-9) is equal to the sum from i=0 to i=t of input_train[i]
This is just a simple example to see how SimpleRNN works. However, when I execute fit function mse doesn't match with the same value calculated by me. What is happening?
modelo = Sequential()
modelo.add(SimpleRNN(1, input_shape=(number_data_in_simulation,1), activation='linear', return_sequences = True))
modelo.add(Dense(units = 1, activation='linear'))
modelo.compile(optimizer=tf.keras.optimizers.Adam(0.1), loss='mse')
historial = modelo.fit(input_train, output_train, batch_size = 1, epochs=1, verbose=1)
predictions = modelo.predict(input_train, batch_size = 1, verbose = False)
mse_value = 0
number_cases = 0
for sim in range(len(output_train)):
for example in range(len(output_train[sim])):
mse_value = mse_value + (output_train[sim][example] - predictions[sim][example][0])**2
number_cases += 1
print(mse_value/number_cases)
IN TERMINAL:
2022-12-15 19:07:11.483935: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2022-12-15 19:07:11.483963: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (jose-HP-EliteBook-830-G7-Notebook-PC): /proc/driver/nvidia/version does not exist
2022-12-15 19:07:11.484223: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
1/1 [==============================] - 0s 467ms/step - loss: 6.1238
5.149037324060892
I expect to have the same result. 6.1238 != 5.149037324060892 Thank you very much! :)