Q:

ValueError: None values not supported when using a placeholder variable in a multiplication operation

I am using the following code inside a network graph in tensorflow:
self.num_quantiles = tf.placeholder(dtype=tf.int32)

num_samples = self.rnn.get_shape().as_list()[0]
quantiles_shape = [self.num_quantiles * num_samples, 1]
self.quantiles = tf.random_uniform(quantiles_shape, minval=0, maxval=1, dtype=tf.float32)

However, I get an error because of the multiplication "None values not supported.".
Can anyone tell me please how to perform the multiplication properly using my placeholder ?
  ---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  <ipython-input-31-4f68d3e68617> in <module>
  2 tf.reset_default_graph()
  3 #We define the primary and target q-networks
  ----> 4 mainQN = Qnetwork('main')
  5 targetQN = Qnetwork('target')
  6 

<ipython-input-27-5b3a3af3cf09> in __init__(self, myScope)
136         #batch_size = state_net.get_shape().as_list()[0]
137         num_samples = self.rnn.get_shape().as_list()[0] #batch_size
--> 138         quantiles_shape = [self.num_quantiles * num_samples, 1]
139         self.quantiles = tf.random_uniform(quantiles_shape, minval=0, maxval=1, dtype=tf.float32)
140 

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py in binary_op_wrapper(x, y)
813       elif not isinstance(y, sparse_tensor.SparseTensor):
814         try:
--> 815           y = ops.convert_to_tensor(y, dtype=x.dtype.base_dtype, name="y")
816         except TypeError:
817           # If the RHS is not a tensor, it might be a tensor aware object

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py in  convert_to_tensor(value, dtype, name, preferred_dtype)
1037     ValueError: If the `value` is a tensor not of given `dtype` in graph mode.
1038   """
-> 1039   return convert_to_tensor_v2(value, dtype, preferred_dtype, name)
1040 
1041 

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape, allow_broadcast)
452   else:
453     if values is None:
--> 454       raise ValueError("None values not supported.")
455     # if dtype is provided, forces numpy array to be the type
456     # provided if possible.

ValueError: None values not supported.

A:

my solution was to do the multiplication operation outside the graph, then provide this value to a new placeholder:
 self.quantiles_shape=tf.placeholder(dtype=tf.int32)
 num_samples = self.rnn.get_shape().as_list()[0]
 self.quantiles = tf.random_uniform([self.quantiles_shape, 1], minval=0, maxval=1, dtype=tf.float32)

This is not ideally what I wanted, but at least it works.

