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

Model subclassing compatibility #26

Open
lminer opened this issue Apr 22, 2022 · 4 comments
Open

Model subclassing compatibility #26

lminer opened this issue Apr 22, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@lminer
Copy link

lminer commented Apr 22, 2022

I've been trying to get this to work with the model subclassing API, but for some reason, the first layer of the model always expects the data to be in float32. Any idea how to get this to work?

@NEGU93
Copy link
Owner

NEGU93 commented Apr 22, 2022

Did you add the ComplexInput layer at the start? If not TF will automatically use the tensorflow Input and cast it to float.

@lminer
Copy link
Author

lminer commented Apr 22, 2022

How would you do that in a subclassed model? I have a custom train and test step so I can't just do:

inputs = ComplexInput((1,2,3))
outputs = SubClassedModel(inputs)
model = tf.keras.Model(inputs, outputs)

@NEGU93
Copy link
Owner

NEGU93 commented Apr 27, 2022

It is possible... did it work? I have never worked with SubCalssedModels, I don't know how they worked. What is the difference from a normal model?

@lminer
Copy link
Author

lminer commented Apr 27, 2022

I couldn't get it to work. In order to use the approach above, I would have needed too big a refactor. Subclassed models are just a pytorch like interface. You just inherit from the normal model and then build the layers in the constructor, and the implementation in call. It's the same as a custom layer, but with a model instead.

@NEGU93 NEGU93 added the bug Something isn't working label May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants