-
Notifications
You must be signed in to change notification settings - Fork 34
mackey-glass problem with LMU giving out the error with the recent updates of keras-lmu 0.2.0 and 0.3.0 versions #25
Copy link
Copy link
Open
Description
<ipython-input-16-f9340b4f7a97> in <module>()
50 layers = 4
51 lstm_model = make_lstm(units=25, layers=layers)
---> 52 lmu_model = make_lmu(units=49, layers=layers)
53 hybrid_model = make_hybrid(units_lstm=25, units_lmu=40, layers=layers)
1 frames
<ipython-input-16-f9340b4f7a97> in delay_layer(units, **kwargs)
18 #memory_d=memory_d,
19 #hidden_cell=tf.keras.layers.SimpleRNNCell(212),
---> 20 theta=4,
21 ),
22 return_sequences=True,
TypeError: __init__() missing 2 required positional arguments: 'memory_d' and 'hidden_cell'
]
Here I passed the missing parameters..
def make_lstm(units, layers):
model = Sequential()
model.add(LSTM(units,
input_shape=(train_X.shape[1], 1), # (timesteps, input_dims)
return_sequences=True)) # continuously outputs per timestep
for _ in range(layers-1):
model.add(LSTM(units, return_sequences=True))
model.add(Dense(train_X.shape[-1], activation='tanh'))
model.compile(loss="mse", optimizer="adam")
model.summary()
return model
def delay_layer(units, **kwargs):
return RNN(LMUCell(units=units,
order=4,
memory_d=4,
hidden_cell=tf.keras.layers.Layer,
#memory_d=memory_d,
#hidden_cell=tf.keras.layers.SimpleRNNCell(212),
theta=4,
),
return_sequences=True,
**kwargs)
def make_lmu(units, layers):
model = Sequential()
model.add(delay_layer(units,
input_shape=(train_X.shape[1], 1))) # (timesteps, input_dims)
for _ in range(layers-1):
model.add(delay_layer(units))
model.add(Dense(train_X.shape[-1], activation='linear'))
model.compile(loss="mse", optimizer="adam")
model.summary()
return model
def make_hybrid(units_lstm, units_lmu, layers):
assert layers == 4, "unsupported"
model = Sequential()
model.add(delay_layer(units=units_lmu,input_shape=(train_X.shape[1], 1)))
model.add(LSTM(units=units_lstm, return_sequences=True))
model.add(delay_layer(units=units_lmu))
model.add(LSTM(units=units_lstm, return_sequences=True))
model.add(Dense(train_X.shape[-1], activation='tanh'))
model.compile(loss="mse", optimizer="adam")
model.summary()
return model
layers = 4
lstm_model = make_lstm(units=25, layers=layers)
lmu_model = make_lmu(units=49, layers=layers)
hybrid_model = make_hybrid(units_lstm=25, units_lmu=40, layers=layers)
Even after passing out the missing parameters giving another error with units, even I installed the latest keras-lmu but same problem I think because version 0.2.0 removed the units and hidden_activation parameters of LMUCell (these are now specified directly in the hidden_cell. (#22) So please provide the updated codes for mackey-glass prediction problem also. Thanks in advance
TypeError Traceback (most recent call last)
<ipython-input-17-1c880cdb37fc> in <module>()
50 layers = 4
51 lstm_model = make_lstm(units=25, layers=layers)
---> 52 lmu_model = make_lmu(units=49, layers=layers)
53 hybrid_model = make_hybrid(units_lstm=25, units_lmu=40, layers=layers)
6 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/utils/generic_utils.py in validate_kwargs(kwargs, allowed_kwargs, error_message)
776 for kwarg in kwargs:
777 if kwarg not in allowed_kwargs:
--> 778 raise TypeError(error_message, kwarg)
779
780
TypeError: ('Keyword argument not understood:', 'units')
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels