Open rohit-shekhar26 opened 4 years ago
It seems like you've bug in your code. I guess you seem to be not binding the function to the object.
In the __init__
, ensure you've the following:
self.decoder_att = nn.Linear(decoder_dim, attention_dim)
Once you have that, you can do the following in the forward
function,
att2 = self.decoder_att(decoder_hidden) # (batch_size, attention_dim)
Once you have both of those in place, be sure to instantiate a callable and bind it the object as in:
self.attention = Attention(encoder_dim, decoder_dim, attention_dim) # attention network
Once you do the above, you can call this which is usually done in the forward
function,
self.attention(encoder_out[:batch_size_t], h[:batch_size_t])
The 2nd argument in the above line is the hidden state.
I appreciate your working and it helped me lot to understand the flow of image captioning.
I got stuck in the decoder part. Kindly help me to understand and debug it.
You have created the encoder_out which contains the extracted features of the image. I want to create the decoder_hidden which is not defined and I am getting the following error.
models.py code line 81
NameError Traceback (most recent call last)