titu1994 / tf_SIREN

Tensorflow 2.0 implementation of Sinusodial Representation networks (SIREN)
MIT License
149 stars 26 forks source link

Loading models that use SIREN #13

Closed Sharan-Babu closed 3 years ago

Sharan-Babu commented 4 years ago

Hi. I am unable to load my SIREN model with the Keras load_model function due to the following errors:

TypeError: __init__() missing 1 required positional argument: 'units'
ValueError: Unknown activation function: Sine

I had trained a CycleGAN model and want to load the saved weights but unable to do so. Kindly look into it.

titu1994 commented 4 years ago

You need to import the library to add the custom objects to Keras.

mk-95 commented 3 years ago

Hi, I was able to avoid this problem by changing the keys of the following dictionary to match the name of the custom_objects https://github.com/titu1994/tf_SIREN/blob/27d385c89c1dc9e988567120e351b1ef2a572b1b/tf_siren/siren.py#L249-L255

I used the following

tf.keras.utils.get_custom_objects().update({
    'Sine': Sine,
    'SIRENInitializer': SIRENInitializer,
    'SIRENFirstLayerInitializer': SIRENFirstLayerInitializer,
    'SinusodialRepresentationDense': SinusodialRepresentationDense,
    'ScaledSinusodialRepresentationDense': ScaledSinusodialRepresentationDense,
})
Sharan-Babu commented 3 years ago

Thanks

saddamhijazi commented 2 years ago

I have done what you suggested, however I got the following error

TypeError: __init__() got an unexpected keyword argument 'scale'

How to solve this ? Thanks.