philipperemy / keras-tcn

Keras Temporal Convolutional Network.
MIT License
1.87k stars 454 forks source link

TypeError when creating a tensorflow.keras model with TCN layer - keras-tcn #199

Closed healthyertech closed 3 years ago

healthyertech commented 3 years ago

Hi all, I have recently started to study temporal convolutional networks and I was trying to implement a model using the keras-tcn library. To get familiar with the library, I tried to run the example script for regression task presented in the README file, but I get the following error when the Sequential model is created:

`Traceback (most recent call last):

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\google\protobuf\internal\python_message.py", line 561, in init copy.MergeFrom(new_val)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\google\protobuf\internal\python_message.py", line 1320, in MergeFrom raise TypeError(

TypeError: Parameter to MergeFrom() must be instance of same class: expected TensorShapeProto got TensorShapeProto.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "", line 1, in m = Sequential([

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\training\tracking\base.py", line 517, in _method_wrapper result = method(self, *args, **kwargs)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\keras\engine\sequential.py", line 117, in init super(functional.Functional, self).init( # pylint: disable=bad-super-call

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\training\tracking\base.py", line 517, in _method_wrapper result = method(self, *args, **kwargs)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\keras\engine\training.py", line 293, in init self._init_batch_counters()

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\training\tracking\base.py", line 517, in _method_wrapper result = method(self, *args, **kwargs)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\keras\engine\training.py", line 301, in _init_batch_counters self._train_counter = variables.Variable(0, dtype='int64', aggregation=agg)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\ops\variables.py", line 262, in call return cls._variable_v2_call(*args, **kwargs)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\ops\variables.py", line 244, in _variable_v2_call return previous_getter(

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\ops\variables.py", line 237, in previous_getter = lambda kws: default_variable_creator_v2(None, kws)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 2654, in default_variable_creator_v2 return resource_variable_ops.ResourceVariable(

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\ops\variables.py", line 264, in call return super(VariableMetaclass, cls).call(*args, **kwargs)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py", line 1574, in init self._init_from_args(

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py", line 1728, in _init_from_args handle = eager_safe_variable_handle(

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py", line 236, in eager_safe_variable_handle return _variable_handle_from_shape_and_dtype(shape, dtype, shared_name, name,

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py", line 176, in _variable_handle_from_shape_and_dtype cpp_shape_inference_pb2.CppShapeInferenceResult.HandleShapeAndType(

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\google\protobuf\internal\python_message.py", line 563, in init _ReraiseTypeErrorWithFieldName(message_descriptor.name, field_name)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\google\protobuf\internal\python_message.py", line 488, in _ReraiseTypeErrorWithFieldName six.reraise(type(exc), exc, sys.exc_info()[2])

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\six.py", line 702, in reraise raise value.with_traceback(tb)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\google\protobuf\internal\python_message.py", line 561, in init copy.MergeFrom(new_val)

File "C:\Users\vince\anaconda3\envs\mlsp_tf2_env\lib\site-packages\google\protobuf\internal\python_message.py", line 1320, in MergeFrom raise TypeError(

TypeError: Parameter to MergeFrom() must be instance of same class: expected TensorShapeProto got TensorShapeProto. for field HandleShapeAndType.shape`

I'm running

Thanks in advance for the answers Cheers

philipperemy commented 3 years ago

Can you try with tensorflow==2.4.1?

I've never seen this error before!

philipperemy commented 3 years ago

I'm going to close this issue as I am unable to reproduce the error. Try to upgrade to the latest tensorflow and it should work like a charm!