Is the reshaper wrong somehow?

Course 5, week 1, assignment 3: djmodel
I get this error:
ValueError: Cannot reshape a tensor with 90 elements to shape [90,1,90] (8100 elements) for ‘{{node reshape/Reshape_5}} = Reshape[T=DT_FLOAT, Tshape=DT_INT32](strided_slice_8, reshape/Reshape_5/shape)’ with input shapes: [90], [3] and with input tensors computed as partial shapes: input[1] = [90,1,90].

I select "t"th time step vector from X with X[-1,t,:] and then pass x to reshaper. The shape before I pass x is (90,) is that wrong?
in the explanation it says it should be (n_values,).


1 Like

That’s the problem (the ‘-1’).

I tried X[:,t,:] before and it gave me another error and I assumed it was wrong, because I reread the instructions ans saw:
“Recall that if you were implementing in numpy instead of Keras, you would extract a slice from a 3D numpy array like this”.
Due to this I thought it was somehow different in Keras than in numpy.
But if it is right like that it is exactly the same as numpy.
I was also looking for a shape like (90,) following instructions…

Anyway, now I have a different error from the LSTM_cell, and I pass as arguments x for inputs and [a,c] for initial_state, but does not work.
Error: TypeError: ‘list’ object is not callable

Even [a0,c0] not working.
Any clue?

Are you sure there is no other place in your code where you are using parens to index into a list? In python, parens mean you are calling a function. If I have a list called myList and I say:

firstElem = myList(0)

I will get exactly the error message you show. The correct syntax for that is:

firstElem = myList[0]

If that’s not it, maybe it’s time to just look at your code. Please check your DMs for a message from me about how to do that.

1 Like

To close the loop on the public thread, the problem was that the code was treating LSTM_cell like a “Layer” function, meaning it returns a function. So it was called as

... LHS ... = LSTM_cell(... arguments ...)(x)

But in this case it was LSTM that is the “Layer” function and they already “instantiated” it for you. So you just call LSTM_cell with the one set of arguments. They actually wrote an example of the correct code for you in the instructions.

1 Like

Thanks a lot for the further explanation.