Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct way to do transfer learning (Keras AssertionError) #5

Open
salexo opened this issue Aug 21, 2018 · 0 comments
Open

Correct way to do transfer learning (Keras AssertionError) #5

salexo opened this issue Aug 21, 2018 · 0 comments

Comments

@salexo
Copy link

salexo commented Aug 21, 2018

Hi, I'm trying to do transfer learning from the provided English net to a custom data set. The readme mentions that even languages with a different number of characters compared to English can be used by supplying the allowed_characters_for_loaded_model parameter, however I'm getting an AssertionError upon execution:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    english = Configuration.english().load_model(load_name=Configuration.english_baseline[0], load_epoch=Configuration.english_baseline[1], allowed_characters_for_loaded_model=new_corpus.frequent_characters)
  File "/usr/local/lib/python3.5/dist-packages/speechless/configuration.py", line 184, in load_model
    reinitialize_trainable_loaded_layers=reinitialize_trainable_loaded_layers)
  File "/usr/local/lib/python3.5/dist-packages/speechless/net.py", line 182, in __init__
    loaded_first_layers_count=frozen_layer_count if reinitialize_trainable_loaded_layers else None)
  File "/usr/local/lib/python3.5/dist-packages/speechless/net.py", line 231, in load_weights
    asg_transition_probabilities=self.asg_transition_probabilities)
  File "/usr/local/lib/python3.5/dist-packages/speechless/net.py", line 182, in __init__
    loaded_first_layers_count=frozen_layer_count if reinitialize_trainable_loaded_layers else None)
  File "/usr/local/lib/python3.5/dist-packages/speechless/net.py", line 212, in load_weights
    self.predictive_net.load_weights(str(load_model_from_directory / self.model_file_name(load_epoch)))
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/network.py", line 1161, in load_weights
    f, self.layers, reshape=reshape)
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/saving.py", line 915, in load_weights_from_hdf5_group
    reshape=reshape)
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/saving.py", line 571, in preprocess_weights_for_loading
    assert shape[0] == layer.filters and shape[2:] == (layer.kernel_size[0], 1)
AssertionError

I'm starting the training by this script:

english = Configuration.english().load_model(load_name=Configuration.english_baseline[0], 
               load_epoch=Configuration.english_baseline[1], 
               allowed_characters_for_loaded_model=new_corpus.frequent_characters)
new = Configuration.new()
new.train(english, run_name="transfer_test_01")

Training from scratch has no problems. What am I doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant