Lesson 12 spelling_bee_rnn.ipynb

I get an error at the cell immediately after having imported attention_wrapper

AttributeError: ‘LSTM’ object has no attribute 'get_output_shape_for’

Can someone help in deciphering the cause of this error? Thanks in advance !!

The full trace is as under:

AttributeError Traceback (most recent call last)
in ()
8 x = get_rnn()(x)
9 x = get_rnn()(x)
—> 10 x = Attention(get_rnn, 3)([x, emb_dec])
11 x = TimeDistributed(Dense(output_vocab_size, activation=‘softmax’))(x)

~/py36/lib/python3.6/site-packages/keras/engine/topology.py in call(self, inputs, **kwargs)
592 self.build(input_shapes[0])
593 else:
–> 594 self.build(input_shapes)
595 self.built = True

~/Documents/fastai/courses/deeplearning2/attention_wrapper.py in build(self, input_shape)
29 l0 = self.layers[0]
—> 31 out_shape = self.get_output_shape_for(input_shape)
32 for layer in self.layers:
33 if not layer.built: layer.build(out_shape)

~/Documents/fastai/courses/deeplearning2/attention_wrapper.py in get_output_shape_for(self, input_shape)
52 def get_output_shape_for(self, input_shape):
—> 53 return self.layers[0].get_output_shape_for(input_shape[1])

AttributeError: ‘LSTM’ object has no attribute ‘get_output_shape_for’

I noticed that the line

x = Attention(get_rnn, 3)([x, emb_dec])

is passing get_rnn… should this be a string? or call a function like get_rnn()

Has anyone run this notebook?

Hi @sam2

I can’t seem to find this notebook in the github. Think it hasn’t been completely flushed out yet.

Regardles, I’m very interested in the problem that looks like being solved. Would you mind sharing the notebook with me? This looks like it’d also be very helpful for a problem I’m trying to solve myself…


It’s in an older repository:

give it a go