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

When fine tune the ConvMixer with tf.hub has ERROR:absl:hub.KerasLayer is trainable but has zero trainable weights. #5

Open
vscv opened this issue Feb 22, 2022 · 0 comments

Comments

@vscv
Copy link

vscv commented Feb 22, 2022

Describe the bug
When fine tune the ConvMixer with tf.hub has ERROR:absl:hub.KerasLayer is trainable but has zero trainable weights.

To Reproduce
Steps to reproduce the behavior:

Tensorflow 2.6.0
`
resize_input = resize_layer_224(inputs)
rescaling_input = scale_layer_2(resize_input)

base_model = hub.KerasLayer(https://tfhub.dev/rishit-dagli/convmixer-1536-20-fe/1, name = CVMixer, trainable=True)

b_m_output = base_model(rescaling_input)
reshape_output = tf.keras.layers.Reshape((1024,))(b_m_output)
outputs = tf.keras.layers.Dense(outputnum, activation="softmax", name="top_output")(reshape_output)

model = tf.keras.Model(inputs=inputs, outputs=outputs, name=model_name)
model.compile(
optimizer = tf.keras.optimizers.Adam(learning_rate=0.00001),
loss=tf.losses.SparseCategoricalCrossentropy(from_logits=False),
metrics=['accuracy']
)
`

`
ERROR:absl:hub.KerasLayer is trainable but has zero trainable weights.

Traceback (most recent call last):

File "/home/.py", line 1009, in build_tf_hub_models
b_m_output = base_model(rescaling_input)
File "/usr/local/lib/python3.8/dist-packages/keras/engine/base_layer.py", line 976, in call
return self._functional_construction_call(inputs, args, kwargs,
File "/usr/local/lib/python3.8/dist-packages/keras/engine/base_layer.py", line 1114, in _functional_construction_call
outputs = self._keras_tensor_symbolic_call(
File "/usr/local/lib/python3.8/dist-packages/keras/engine/base_layer.py", line 848, in _keras_tensor_symbolic_call
return self._infer_output_signature(inputs, args, kwargs, input_masks)
File "/usr/local/lib/python3.8/dist-packages/keras/engine/base_layer.py", line 888, in _infer_output_signature
outputs = call_fn(inputs, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/autograph/impl/api.py", line 695, in wrapper
raise e.ag_error_metadata.to_exception(e)
ValueError: in user code:

/home/.local/lib/python3.8/site-packages/tensorflow_hub/keras_layer.py:229 call  *
    result = f()
/usr/local/lib/python3.8/dist-packages/tensorflow/python/saved_model/load.py:664 _call_attribute  **
    return instance.__call__(*args, **kwargs)
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/def_function.py:885 __call__
    result = self._call(*args, **kwds)
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/def_function.py:933 _call
    self._initialize(args, kwds, add_initializers_to=initializers)
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/def_function.py:759 _initialize
    self._stateful_fn._get_concrete_function_internal_garbage_collected(  # pylint: disable=protected-access
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/function.py:3066 _get_concrete_function_internal_garbage_collected
    graph_function, _ = self._maybe_define_function(args, kwargs)
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/function.py:3463 _maybe_define_function
    graph_function = self._create_graph_function(args, kwargs)
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/function.py:3298 _create_graph_function
    func_graph_module.func_graph_from_py_func(
/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/func_graph.py:1007 func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/def_function.py:668 wrapped_fn
    out = weak_wrapped_fn().__wrapped__(*args, **kwds)
/usr/local/lib/python3.8/dist-packages/tensorflow/python/saved_model/function_deserialization.py:288 restored_function_body
    raise ValueError(

ValueError: Could not find matching function to call loaded from the SavedModel. Got:
  Positional arguments (1 total):
    * Tensor("None_0:0", shape=(None, 224, 224, 3), dtype=float32)
  Keyword arguments: {}

Expected these arguments to match one of the following 1 option(s):

Option 1:
  Positional arguments (0 total):
    * 
  Keyword arguments: {'input': TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='input')}`

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

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