A1: modelf()

I am getting this error when running modelf().

Layer lstm expects 7 inputs, but it received 3 input tensors. Inputs received: [<tf.Tensor ‘dot/MatMul_22:0’ shape=(None, 1, 64) dtype=float32>, <tf.Tensor ‘s0_10:0’ shape=(None, 64) dtype=float32>, <tf.Tensor ‘c0_10:0’ shape=(None, 64) dtype=float32>]

There seems to be an issue with post_activation_LSTM_cell(). Are the inputs only: context and initial_state = [s, c] or I am missing something.


Both assignments in DLS C5 W3 have functions called modelf(), but it looks like you are talking about the Neural Machine Translation assignment.

Yes, you’re right about the inputs to the post_activation_LSTM_cell, but note that is just an instantiation of the parent LSTM class and that has its own definition, which is presumably where the info about 7 inputs is coming from. Because of the complex way all these things are instantiated, one easy thing to check first is just make sure that your notebook is in a consistent state. Try this:

  1. Kernel → Restart and Clear Output
  2. Save
  3. Cell → Run All

Now page through carefully from the top and see if any errors are being thrown. If not, then it was just a problem with out of sync state and your code is correct.

If you still get the same error, then it’s time to go to the next level of debugging. I did not get that error, so there must be some way in which your input objects are not matching what is expected.

Yes, I started executing from the top and the error went away. Thanks for your response.