Open sagagk opened 1 year ago
Here is my test code and procedure:
import numpy as np
from tensorflow.keras.layers import Input, LSTM, Dense
from tensorflow.keras.models import Model
revin_layer = RevIN()
x=Input(shape=(12, 2))
model=revin_layer(x,mode="norm")
model2=LSTM(32, return_sequences=False)(model)
output_layer=Dense(2)(model2)
output_layer1=revin_layer(output_layer,mode="denorm")
model1 = Model(inputs=x, outputs=output_layer1)
model1.summary()
model1.compile(optimizer='Adam', loss='mse')
x = np.random.randn(16, 12, 2)
y = np.random.randn(16, 2)
model1.fit(x=x, y=y, epochs=10, batch_size=1)
Model: "functional_1"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_1 (InputLayer) [(None, 12, 2)] 0
__________________________________________________________________________________________________
rev_in (RevIN) multiple 4 input_1[0][0]
dense[0][0]
__________________________________________________________________________________________________
lstm (LSTM) (None, 32) 4480 rev_in[0][0]
__________________________________________________________________________________________________
dense (Dense) (None, 2) 66 lstm[0][0]
==================================================================================================
Total params: 4,550
Trainable params: 4,550
Non-trainable params: 0
__________________________________________________________________________________________________
Epoch 1/10
16/16 [==============================] - 0s 2ms/step - loss: 0.9344
Epoch 2/10
16/16 [==============================] - 0s 2ms/step - loss: 0.9181
Epoch 3/10
16/16 [==============================] - 0s 2ms/step - loss: 0.9076
Epoch 4/10
16/16 [==============================] - 0s 2ms/step - loss: 0.9027
Epoch 5/10
16/16 [==============================] - 0s 2ms/step - loss: 0.8949
Epoch 6/10
16/16 [==============================] - 0s 2ms/step - loss: 0.8884
Epoch 7/10
16/16 [==============================] - 0s 2ms/step - loss: 0.8836
Epoch 8/10
16/16 [==============================] - 0s 2ms/step - loss: 0.8786
Epoch 9/10
16/16 [==============================] - 0s 2ms/step - loss: 0.8713
Epoch 10/10
16/16 [==============================] - 0s 3ms/step - loss: 0.8663
This is my part of packages:
tensorflow==2.3.0
numpy==1.19.5
Maybe you can check your environment. This is my suggestion currently.
I call your function from:
But I obtain error.. I appears to be in the backpropagation phase. The output:
I see that your simple demo works, but when I train a neural network, appears this "out of scope" error.