pointer-networks-experiments
                                
                                 pointer-networks-experiments copied to clipboard
                                
                                    pointer-networks-experiments copied to clipboard
                            
                            
                            
                        Running train.py as-is leads to AttributeError
Hello, thanks for your work!
Keras2 branch seems to be broken; I've installed keras==2.0.0 and I get
Traceback (most recent call last):
  File "/home/aam/projects/aam_word_sorting/pointer-networks-experiments/train.py", line 53, in <module>
    decoder = PointerLSTM(hidden_size, units=hidden_size, name="decoder")(encoder)
  File "/usr/local/lib/python3.5/dist-packages/keras/layers/recurrent.py", line 252, in __call__
    return super(Recurrent, self).__call__(inputs, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 545, in __call__
    output = self.call(inputs, **kwargs)
  File "/home/aam/projects/aam_word_sorting/pointer-networks-experiments/PointerLSTM.py", line 43, in call
    initial_states = self.get_initial_states(x_input)
  File "/home/aam/projects/aam_word_sorting/pointer-networks-experiments/PointerLSTM.py", line 17, in get_initial_states
    return Recurrent.get_initial_state(self, x_input)
AttributeError: type object 'Recurrent' has no attribute 'get_initial_state'
when trying to run train.py without any modifications.
When I replace it with return Recurrent.get_initial_states(self, x_input), I get the following error message:
loading weights from model_weights/model_weights_5_steps_64.hdf5...
Traceback (most recent call last):
  File "/home/aam/projects/aam_word_sorting/pointer-networks-experiments/train.py", line 59, in <module>
    model.load_weights(weights_file)
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 2482, in load_weights
    load_weights_from_hdf5_group(f, self.layers)
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 2893, in load_weights_from_hdf5_group
    ' elements.')
ValueError: Layer #1 (named "decoder" in the current model) was found to correspond to layer decoder in the save file. However the new layer decoder expects 9 weights, but the saved weights have 15 elements.
Could you please suggest hints on any ways to fix it?
Thanks in advance! Best regards.
You might want to ask @shagunsodhani, the author of the Keras2 branch. https://github.com/zygmuntz/pointer-networks-experiments/pull/1
Thanks for tagging me @zygmuntz.
@alexeyev it seems that the problem is because the persisted models (in model_wieghts dir) are corresponding to older version of keras. Let me push the models trained with the new code.
@alexeyev https://github.com/zygmuntz/pointer-networks-experiments/pull/6/ This contains the new models.
@zygmuntz @shagunsodhani Many thanks!
@zygmuntz in train_with_positions.py should we take the positions of words in the vocabulary ? Can you elaborate a bit on the training and test data to be used for a problem of rearranging words in a sentence by taking train_with_positions.py