keras使用顺序模型出错

配置为M1 pro芯片,keras==2.6.0
model = Sequential()


TypeError                                 Traceback (most recent call last)
/var/folders/h0/j1d38bxd4295htjpcn2wwpwc0000gn/T/ipykernel_48710/1518389220.py in <module>
----> 1 model = Sequential()

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
    528     self._self_setattr_tracking = False  # pylint: disable=protected-access
    529     try:
--> 530       result = method(self, *args, **kwargs)
    531     finally:
    532       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access

~/anaconda3/envs/py39/lib/python3.9/site-packages/keras/engine/sequential.py in __init__(self, layers, name)
    105     """
    106     # Skip the init in FunctionalModel since model doesn't have input/output yet
--> 107     super(functional.Functional, self).__init__(  # pylint: disable=bad-super-call
    108         name=name, autocast=False)
    109     base_layer.keras_api_gauge.get_cell('Sequential').set(True)

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
    528     self._self_setattr_tracking = False  # pylint: disable=protected-access
    529     try:
--> 530       result = method(self, *args, **kwargs)
    531     finally:
    532       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access

~/anaconda3/envs/py39/lib/python3.9/site-packages/keras/engine/training.py in __init__(self, *args, **kwargs)
    287     self._steps_per_execution = None
    288 
--> 289     self._init_batch_counters()
    290     self._base_model_initialized = True
    291 

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
    528     self._self_setattr_tracking = False  # pylint: disable=protected-access
    529     try:
--> 530       result = method(self, *args, **kwargs)
    531     finally:
    532       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access

~/anaconda3/envs/py39/lib/python3.9/site-packages/keras/engine/training.py in _init_batch_counters(self)
    295     # `evaluate`, and `predict`.
    296     agg = tf.VariableAggregation.ONLY_FIRST_REPLICA
--> 297     self._train_counter = tf.Variable(0, dtype='int64', aggregation=agg)
    298     self._test_counter = tf.Variable(0, dtype='int64', aggregation=agg)
    299     self._predict_counter = tf.Variable(

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/ops/variables.py in __call__(cls, *args, **kwargs)
    266       return cls._variable_v1_call(*args, **kwargs)
    267     elif cls is Variable:
--> 268       return cls._variable_v2_call(*args, **kwargs)
    269     else:
    270       return super(VariableMetaclass, cls).__call__(*args, **kwargs)

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/ops/variables.py in _variable_v2_call(cls, initial_value, trainable, validate_shape, caching_device, name, variable_def, dtype, import_scope, constraint, synchronization, aggregation, shape)
    248     if aggregation is None:
    249       aggregation = VariableAggregation.NONE
--> 250     return previous_getter(
    251         initial_value=initial_value,
    252         trainable=trainable,

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/ops/variables.py in <lambda>(**kws)
    241                         shape=None):
    242     """Call on Variable class. Useful to force the signature."""
--> 243     previous_getter = lambda **kws: default_variable_creator_v2(None, **kws)
    244     for _, getter in ops.get_default_graph()._variable_creator_stack:  # pylint: disable=protected-access
    245       previous_getter = _make_getter(getter, previous_getter)

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/ops/variable_scope.py in default_variable_creator_v2(next_creator, **kwargs)
   2660   shape = kwargs.get("shape", None)
   2661 
-> 2662   return resource_variable_ops.ResourceVariable(
   2663       initial_value=initial_value,
   2664       trainable=trainable,

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/ops/variables.py in __call__(cls, *args, **kwargs)
    268       return cls._variable_v2_call(*args, **kwargs)
    269     else:
--> 270       return super(VariableMetaclass, cls).__call__(*args, **kwargs)
    271 
    272 

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/ops/resource_variable_ops.py in __init__(self, initial_value, trainable, collections, validate_shape, caching_device, name, dtype, variable_def, import_scope, constraint, distribute_strategy, synchronization, aggregation, shape)
   1600       self._init_from_proto(variable_def, import_scope=import_scope)
   1601     else:
-> 1602       self._init_from_args(
   1603           initial_value=initial_value,
   1604           trainable=trainable,

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/ops/resource_variable_ops.py in _init_from_args(self, initial_value, trainable, collections, caching_device, name, dtype, constraint, synchronization, aggregation, distribute_strategy, shape)
   1754           else:
   1755             shape = initial_value.shape
-> 1756           handle = eager_safe_variable_handle(
   1757               initial_value=initial_value,
   1758               shape=shape,

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/ops/resource_variable_ops.py in eager_safe_variable_handle(initial_value, shape, shared_name, name, graph_mode)
    236   """
    237   dtype = initial_value.dtype.base_dtype
--> 238   return _variable_handle_from_shape_and_dtype(shape, dtype, shared_name, name,
    239                                                graph_mode, initial_value)
    240 

~/anaconda3/envs/py39/lib/python3.9/site-packages/tensorflow/python/ops/resource_variable_ops.py in _variable_handle_from_shape_and_dtype(shape, dtype, shared_name, name, graph_mode, initial_value)
    176     handle_data.is_set = True
    177     handle_data.shape_and_type.append(
--> 178         cpp_shape_inference_pb2.CppShapeInferenceResult.HandleShapeAndType(
    179             shape=shape.as_proto(), dtype=dtype.as_datatype_enum))
    180 

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


我的解答思路和尝试过的方法
我想要达到的结果

img

img