Help needed with the Jazz assignment, step 2, creating djmodel

I’m having issue with Programming Assignment: Jazz Improvisation with LSTM, Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera.

My code reads something like the following:

{moderator edit - solution code removed}

And I got error in the unit test:

['TensorFlowOpLayer', [(None, 90)], 0] 

 does not match the input value: 

['Lambda', (None, 90), 0]

Any hints what is wrong?

Please don’t post your code on the forum. That’s not allowed by the Code of Conduct.

Why are you using a Lambda() function? Nothing in the notebook instructions says you should use a lambda function.

Sorry, will not post my code then.

For the Lambda, it’s imported in the import section, so I thought I might be able to use it. There’s one line giving hint:

“* Recall that if you were implementing in numpy instead of Keras, you would extract a slice from a 3D numpy array like this:”

In this case, I need to take a slice that’s feed in as input X = Input(shape=(Tx, n_values), name="INPUT"), at particular time t. Checking on Lambda and example, I thought the construct Lambda(lambda x: x[:, t, :], name="Slice_"+str(t))(X) would do "Step 2.A: select the “t"th time step vector from X”.

I think I understand that I need to extract a 2D slice from a 3D input tensor, but I’m sure how.

Oh, I tried just use X[:, t, :] and it works!

1 Like

That is the expected method.