9阅网

您现在的位置是:首页 > 知识 > 正文

知识

python - TensorType不支持的dtype: dtype: int32 当在jupyter笔记本上使用conda env运行Mask RCNN与Tensorflow 1的训练时。

admin2022-11-07知识16

这是一个有点奇怪的我,因为我运行这个笔记本几天前,很多时候之前没有类似的东西。额外我发现这个GitHub的 发出

在MacOS上

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/miniconda3/envs/mask_rcnn/lib/python3.6/site-packages/theano/tensor/type.py in dtype_specs(self)
    268                 'complex64': (complex, 'theano_complex64', 'NPY_COMPLEX64')
--> 269             }[self.dtype]
    270         except KeyError:

KeyError: "<dtype: 'int32'>"

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-10-36f43ebc6563> in <module>
----> 1 model = modellib.MaskRCNN(mode="training", config=config, model_dir=MODEL_DIR)

~/Study/Project07 - MaskRCNN/mrcnn/model.py in __init__(self, mode, config, model_dir)
   2041         self.model_dir = model_dir
   2042         self.set_log_dir()
-> 2043         self.keras_model = self.build(mode=mode, config=config)
   2044 
   2045     def build(self, mode, config):

~/Study/Project07 - MaskRCNN/mrcnn/model.py in build(self, mode, config)
   2066             # RPN GT
   2067             input_rpn_match = KL.Input(
-> 2068                 shape=[None, 1], name="input_rpn_match", dtype=tf.int32)
   2069             input_rpn_bbox = KL.Input(
   2070                 shape=[None, 4], name="input_rpn_bbox", dtype=tf.float32)

~/miniconda3/envs/mask_rcnn/lib/python3.6/site-packages/keras/engine/topology.py in Input(shape, batch_shape, name, dtype, sparse, tensor)
   1461                              name=name, dtype=dtype,
   1462                              sparse=sparse,
-> 1463                              input_tensor=tensor)
   1464     # Return tensor including _keras_shape and _keras_history.
   1465     # Note that in this case train_output and test_output are the same pointer.

~/miniconda3/envs/mask_rcnn_old2/lib/python3.6/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
     89                 warnings.warn('Update your `' + object_name +
     90                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 91             return func(*args, **kwargs)
     92         wrapper._original_function = func
     93         return wrapper

~/miniconda3/envs/mask_rcnn/lib/python3.6/site-packages/keras/engine/topology.py in __init__(self, input_shape, batch_size, batch_input_shape, dtype, input_tensor, sparse, name)
   1370                                          dtype=dtype,
   1371                                          sparse=self.sparse,
-> 1372                                          name=self.name)
   1373         else:
   1374             self.is_placeholder = False

~/miniconda3/envs/mask_rcnn/lib/python3.6/site-packages/keras/backend/theano_backend.py in placeholder(shape, ndim, dtype, sparse, name)
    237         x = th_sparse_module.csr_matrix(name=name, dtype=dtype)
    238     else:
--> 239         x = T.TensorType(dtype, broadcast)(name)
    240     x._keras_shape = shape
    241     x._uses_learning_phase = False

~/miniconda3/envs/mask_rcnn/lib/python3.6/site-packages/theano/tensor/type.py in __init__(self, dtype, broadcastable, name, sparse_grad)
     49         # True or False
     50         self.broadcastable = tuple(bool(b) for b in broadcastable)
---> 51         self.dtype_specs()  # error checking is done there
     52         self.name = name
     53         self.numpy_dtype = np.dtype(self.dtype)

~/miniconda3/envs/mask_rcnn/lib/python3.6/site-packages/theano/tensor/type.py in dtype_specs(self)
    270         except KeyError:
    271             raise TypeError("Unsupported dtype for %s: %s"
--> 272                             % (self.__class__.__name__, self.dtype))
    273 
    274     def to_scalar_type(self):

TypeError: Unsupported dtype for TensorType: <dtype: 'int32'>


【回答】:

我仍然不知道是什么问题,但它的消失后,关闭jupyter,停用conda和。重开 终端、conda env、jupyter等。