Reputation: 21
I am attempting to write a tensorflow script for training an image segmentation using the graph structure of the FCN_8s
model. I'm adapting the code from some online tutorials, and there is clearly something (or many things) I am doing wrong. When I try and define the optimizer using adam optimizer (see below) I get a valueError
indicating Tried to convert 'values' to a tensor and failed. Error: None values not supported.
Here is how I am initializing the optimizer and defining the loss function, which is called later in a tf.session()
cross_entropies = tf.nn.softmax_cross_entropy_with_logits_v2(logits=flat_logits,
labels=flat_labels)
cross_entropy_sum = tf.reduce_sum(cross_entropies)
with tf.variable_scope("adam_vars"):
optimizer = tf.train.AdamOptimizer(learning_rate=0.0001)
gradients = optimizer.compute_gradients(loss=cross_entropy_sum)
for grad_var_pair in gradients:
current_variable = grad_var_pair[1]
current_gradient = grad_var_pair[0]
gradient_name_to_save = current_variable.name.replace(":", "_")
tf.summary.histogram(gradient_name_to_save, current_gradient)
Calling tf.trainable_variables
shows that there are variables. I think the issue might be with the cross_entropy_sum
? Using get_shape(cross_entropy_sum)
returns ()
, but if I use the keepdims
option, the shape is (1,)
but I get the same error.
Here is the error traceback:
WARNING:tensorflow:From C:\programs\python\python36\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version. Instructions for updating: Use the retry module or similar alternatives. Traceback (most recent call last): File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 510, in _apply_op_helper preferred_dtype=default_dtype) File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1040, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\constant_op.py", line 235, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\constant_op.py", line 214, in constant value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 421, in make_tensor_proto raise ValueError("None values not supported.") ValueError: None values not supported.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 524, in _apply_op_helper values, as_ref=input_arg.is_ref).dtype.name File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1040, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\constant_op.py", line 235, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\constant_op.py", line 214, in constant value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 421, in make_tensor_proto raise ValueError("None values not supported.") ValueError: None values not supported.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "P:\macro and programming files\TFpy\TFcarcassimageseg3.py", line 252, in tf.summary.histogram(gradient_name_to_save, current_gradient) File "C:\programs\python\python36\lib\site-packages\tensorflow\python\summary\summary.py", line 196, in histogram tag=tag, values=values, name=scope) File "C:\programs\python\python36\lib\site-packages\tensorflow\python\ops\gen_logging_ops.py", line 308, in _histogram_summary "HistogramSummary", tag=tag, values=values, name=name) File "C:\programs\python\python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 528, in _apply_op_helper (input_name, err)) ValueError: Tried to convert 'values' to a tensor and failed. Error: None values not supported.
I'm out of my depth here, but I would appreciate any pointers in resolving this error, thanks!
Upvotes: 2
Views: 1629
Reputation: 428
None values not supported.
This happens if you use a TensorFlow instruction on a variable containing none. I used if g is not None:
as apply_gradients(...)
is using it!
Upvotes: 1