tensorflow: ValueError: Attempt to convert a value (None) with an unsupported type () to a Tensor.

I train faster RCNN for medical image classification in Google Colab. I get the following error and dont know how to fix it. This is the github page I use: https://github.com/you359/Keras-FasterRCNN/blob/master/README.md

Traceback (most recent call last):
  File "train_frcnn.py", line 145, in <module>
    shared_layers = nn.nn_base(img_input, trainable=True)
  File "/content/drive/My Drive/FasterRCNN/FASTER_RCNN_1.1/FASTER_RCNN/keras_frcnn/resnet.py", line 189, in nn_base
    x = FixedBatchNormalization(axis=bn_axis, name='bn_conv1')(x)
  File "/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py", line 75, in symbolic_fn_wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/keras/engine/base_layer.py", line 463, in __call__
    self.build(unpack_singleton(input_shapes))
  File "/content/drive/My Drive/FasterRCNN/FASTER_RCNN_1.1/FASTER_RCNN/keras_frcnn/FixedBatchNormalization.py", line 30, in build
    trainable=False)
  File "/usr/local/lib/python3.6/dist-packages/keras/engine/base_layer.py", line 279, in add_weight
    weight = K.variable(initializer(shape, dtype=dtype),
  File "/usr/local/lib/python3.6/dist-packages/keras/initializers.py", line 46, in __call__
    return K.constant(1, shape=shape, dtype=dtype)
  File "/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py", line 649, in constant
    value, dtype=dtype, shape=shape, name=name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/backend.py", line 970, in constant
    return constant_op.constant(value, dtype=dtype, shape=shape, name=name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py", line 262, in constant
    allow_broadcast=True)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py", line 291, in _constant_impl
    return _eager_fill(shape.as_list(), t, ctx)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py", line 52, in _eager_fill
    dims = convert_to_eager_tensor(dims, ctx, dtypes.int32)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py", line 96, in convert_to_eager_tensor
    return ops.EagerTensor(value, ctx.device_name, dtype)
**ValueError: Attempt to convert a value (None) with an unsupported type (<class 'NoneType'>) to a Tensor.**

I could not find any threat that can help to fix this issue in the Google Colab. Thanks for any input.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (2 by maintainers)

Most upvoted comments

I have the same problem. I modified scripts because I am using TF2 so I updated from tf.placeholder to tf.Variable and then I found this error.

#TF1 #tf.placeholder(tf.int32, shape=(None, None), name=‘inputs’), #tf.placeholder(tf.int32, shape=(None, ), name=‘input_lengths’), #tf.placeholder(tf.float32, shape=(None, None, hparams.num_mels), name=‘mel_targets’), #tf.placeholder(tf.float32, shape=(None, None), name=‘token_targets’), #tf.placeholder(tf.float32, shape=(None, None, hparams.num_freq), name=‘linear_targets’), #tf.placeholder(tf.int32, shape=(None, ), name=‘targets_lengths’), #tf.placeholder(tf.int32, shape=(hparams.tacotron_num_gpus, None), name=‘split_infos’), #TF2 tf.Variable(tf.zeros(shape=(None, None)), name=‘inputs’, dtype=tf.int32), tf.Variable(tf.zeros(shape=(None, )), name=‘input_lengths’, dtype=tf.int32), tf.Variable(tf.zeros(shape=(None, None, hparams.num_mels)), name=‘mel_targets’, dtype=tf.float32), tf.Variable(tf.zeros(shape=(None, None)), name=‘token_targets’, dtype=tf.float32), tf.Variable(tf.zeros(shape=(None, None, hparams.num_freq)), name=‘linear_targets’, dtype=tf.float32), tf.Variable(tf.zeros(shape=(None, )), name=‘targets_lengths’, dtype=tf.int32), tf.Variable(tf.zeros(shape=(hparams.tacotron_num_gpus, None)), name=‘split_infos’, dtype=tf.int32),

Hi, have you solve the error? I am facing the same problem here

I have the same problem. I modified scripts because I am using TF2 so I updated from tf.placeholder to tf.Variable and then I found this error.

#TF1 #tf.placeholder(tf.int32, shape=(None, None), name=‘inputs’), #tf.placeholder(tf.int32, shape=(None, ), name=‘input_lengths’), #tf.placeholder(tf.float32, shape=(None, None, hparams.num_mels), name=‘mel_targets’), #tf.placeholder(tf.float32, shape=(None, None), name=‘token_targets’), #tf.placeholder(tf.float32, shape=(None, None, hparams.num_freq), name=‘linear_targets’), #tf.placeholder(tf.int32, shape=(None, ), name=‘targets_lengths’), #tf.placeholder(tf.int32, shape=(hparams.tacotron_num_gpus, None), name=‘split_infos’), #TF2 tf.Variable(tf.zeros(shape=(None, None)), name=‘inputs’, dtype=tf.int32), tf.Variable(tf.zeros(shape=(None, )), name=‘input_lengths’, dtype=tf.int32), tf.Variable(tf.zeros(shape=(None, None, hparams.num_mels)), name=‘mel_targets’, dtype=tf.float32), tf.Variable(tf.zeros(shape=(None, None)), name=‘token_targets’, dtype=tf.float32), tf.Variable(tf.zeros(shape=(None, None, hparams.num_freq)), name=‘linear_targets’, dtype=tf.float32), tf.Variable(tf.zeros(shape=(None, )), name=‘targets_lengths’, dtype=tf.int32), tf.Variable(tf.zeros(shape=(hparams.tacotron_num_gpus, None)), name=‘split_infos’, dtype=tf.int32),