Deep-Learning-Specialization-Coursera icon indicating copy to clipboard operation
Deep-Learning-Specialization-Coursera copied to clipboard

ERROR in week 3 Machine Translation

Open Yumlembam opened this issue 5 years ago • 4 comments

Hi,

In the line ----> 8 prediction = model.predict([source, s0, c0])

why am i getting the error "Error when checking : expected X to have 3 dimensions, but got array with shape (37, 30)"

Yumlembam avatar Sep 17 '18 16:09 Yumlembam

Is there any resolution for this error yet? I am facing similar error. I am using Keras- "2.2.4"

piyushsoni27 avatar Jun 20 '19 12:06 piyushsoni27

I have the same error also

esraahisham753 avatar Oct 13 '19 12:10 esraahisham753

I edited code with this:

source = string_to_int(example, Tx, human_vocab) source = np.array(list(map(lambda x: to_categorical(x, num_classes=len(human_vocab)), source))) ttt=np.expand_dims(source,axis=0) print(ttt.shape) prediction = model.predict([ttt, s0, c0])

Then, I got another error: ValueError: Data cardinality is ambiguous: x sizes: 1, 10000, 10000 Please provide data which shares the same first dimension.

I downgraded TF version to 2.0.0 instead of 2.3.0.

Anybody able to solve the issue? I am stuck on this.

shanghaiJ avatar Dec 09 '20 21:12 shanghaiJ

i changed this line of code and worked:

prediction = model.predict([np.einsum('ij->ji', source).reshape((1,30,37)), s0[:1], c0[:1]])

alfredomaussa avatar Dec 22 '20 13:12 alfredomaussa