不支持的 dtype 用于 TensorType: <dtype: 'int32'> 在 jupyter notebook 上运行带有 conda env 的 Tensorflow 1



这对我来说有点奇怪,因为我在几天前和之前多次运行这个笔记本都没有类似的东西。 另外我发现了这个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 等后,它已经消失了。

最新更新