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

Run into "KeyError: 'name'" when converting. #200

Closed
dustinjoe opened this issue Jun 24, 2020 · 2 comments
Closed

Run into "KeyError: 'name'" when converting. #200

dustinjoe opened this issue Jun 24, 2020 · 2 comments

Comments

@dustinjoe
Copy link

dustinjoe commented Jun 24, 2020

When I am trying to convert an autoencoder Keras model using command 'hls4ml convert -c keras-auto-config.yml
Loading configuration from keras-auto-config.yml'. Run into error like this:

Interpreting Sequential
Input shape: [200]
Topology:
Layer name: dense_1, layer type: Dense, current shape: [[None, 200]]
Layer name: activation_1, layer type: Activation, current shape: [[None, 256]]
Traceback (most recent call last):
  File "/home/xyzhou/anaconda3/bin/hls4ml", line 138, in <module>
    main()
  File "/home/xyzhou/anaconda3/bin/hls4ml", line 58, in main
    args.func(args)
  File "/home/xyzhou/anaconda3/bin/hls4ml", line 87, in convert
    model = hls4ml.converters.keras_to_hls(yamlConfig)
  File "/home/xyzhou/anaconda3/lib/python3.7/site-packages/hls4ml/converters/keras_to_hls.py", line 174, in keras_to_hls
    output_shapes[keras_layer['name']] = input_shapes #[0]
KeyError: 'name'

The model arch is like this:
input_dim = 200 in my case

def autoencoder_mlp0(input_dim):
    model = Sequential()
    model.add(Dense(256, input_dim=input_dim))
    model.add(Activation('relu'))
    model.add(Dropout(0.2))
    model.add(Dense(128))
    model.add(Activation('relu'))    
    model.add(Dropout(0.2))
    model.add(Dense(256))
    model.add(Activation('relu'))
    model.add(Dropout(0.2))
    model.add(Dense(input_dim, activation='linear'))
    
    model.summary()

    return model

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Anything I can do to deal with this?
Thank you!
@vloncar
Copy link
Contributor

vloncar commented Jun 24, 2020

This is because you use a Sequential model. We have fixed this issue in the branch for PR #195, so you can try using that branch (soon to be master anyway), or you can manually fix it applying the change from e492ae7.

@dustinjoe
Copy link
Author

Thank you very much.
This solution works.

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

2 participants