farizrahman4u / seq2seq

Sequence to Sequence Learning with Keras
GNU General Public License v2.0
3.17k stars 846 forks source link

UnboundLocalError: local variable 'output' referenced before assignment #251

Closed arnaldog12 closed 6 years ago

arnaldog12 commented 6 years ago

Hi,

I'm trying to create the following model:

model = SimpleSeq2Seq(input_dim=7, hidden_dim=10, output_length=5, output_dim=7, depth=3)
model.compile(loss='mse', optimizer='rmsprop')

but I'm getting the following error:

UnboundLocalError                         Traceback (most recent call last)
<ipython-input-14-f533e04825be> in <module>()
----> 1 model = Seq2Seq(batch_input_shape=x_train.shape, hidden_dim=10, output_length=ANSWER_LENGTH, output_dim=len(map_to_char), depth=4)
      2 model.compile(loss='mse', optimizer='rmsprop')

~\Miniconda3\envs\tensorflow\lib\site-packages\seq2seq\models.py in Seq2Seq(output_dim, output_length, batch_input_shape, input_shape, batch_size, input_dim, input_length, hidden_dim, depth, broadcast_state, unroll, stateful, inner_broadcast_state, teacher_force, peek, dropout)
    182     _input._keras_history[0].supports_masking = True
    183     encoded_seq = dense1(_input)
--> 184     encoded_seq = encoder(encoded_seq)
    185     if broadcast_state:
    186         assert type(encoded_seq) is list

~\Miniconda3\envs\tensorflow\lib\site-packages\recurrentshop\engine.py in __call__(self, inputs, initial_state, initial_readout, ground_truth, **kwargs)
    474         with K.name_scope(self.name):
    475             if not self.built:
--> 476                 self.build(K.int_shape(inputs[0]))
    477                 if self._initial_weights is not None:
    478                     self.set_weights(self._initial_weights)

~\Miniconda3\envs\tensorflow\lib\site-packages\recurrentshop\engine.py in build(self, input_shape)
    974                     final_states = cell_out[1:]
    975                 else:
--> 976                     output = cell(output)
    977         else:
    978             if type(input_shape) is list:

~\Miniconda3\envs\tensorflow\lib\site-packages\keras\engine\topology.py in __call__(self, inputs, **kwargs)
    543 
    544             # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 545             output = self.call(inputs, **kwargs)
    546             output_mask = self.compute_mask(inputs, previous_mask)
    547 

~\Miniconda3\envs\tensorflow\lib\site-packages\keras\layers\core.py in call(self, inputs, training)
    110             output = K.in_train_phase(dropped_inputs, inputs,
    111                                       training=training)
--> 112         return output
    113 
    114     def get_config(self):

UnboundLocalError: local variable 'output' referenced before assignment

How can I solve it, please?

ty5491003 commented 6 years ago

the same issue, can u tell me what should i do? please!