lundi 20 septembre 2021

How to use tf.random for tensors whose shape is None

x = tf.placeholder(tf.float32, (None, 2))
noise = tf.random_uniform(shape=x.get_shape)  # error
x += noise

TypeError: Expected binary or unicode string, got <bound method Tensor.get_shape of <tf.Tensor 'Placeholder:0' shape=(?, 2) dtype=float32>>

TypeError: Failed to convert object of type <class 'method'> to Tensor. Contents: <bound method Tensor.get_shape of <tf.Tensor 'Placeholder:0' shape=(?, 2) dtype=float32>>. Consider casting elements to a supported type.

How can I add noise to the tensor whose shape is None. The input parameter shape of tf's random function does not seem to be None, so what should I do?




Aucun commentaire:

Enregistrer un commentaire