7
我基本上想要将选项输入到图形中间并计算从那里输出。我的一个想法是使用默认为零张量的tf.placeholder_with_default
。然后我可以使用加法混合可选输入,但是在大的形状上添加这似乎是很多不必要的计算。有没有更好的方法来完成?如何将可选输入添加到TensorFlow中的图形中?
input_enabled = tf.placeholder_with_default(tf.constant(1.), [1])
input_shape = [None, in_size]
input = tf.placeholder_with_default(tf.zeros(input_shape), input_shape)
// ...
bottleneck_shape = [None, bottleneck_size]
bottleneck = input_enabled * f(prev_layer) + tf.placeholder_with_default(tf.zeros(bottleneck_shape), bottleneck_shape)
// ...
// Using graph with input at first layer:
sess.run([output], feed_dict={input: x})
// Using graph with input at bottleneck layer:
sess.run([output], feed_dict={bottleneck: b, input_enabled: 0.})
你能给出一个更具体的问题概述吗?你想要什么类型的可选输入,并做什么? –
A有一个类似autoencoder的图形,我想用一个用于训练的图形重建代码作为瓶颈输入。 –
你可以给你现在使用'tf.placeholder_with_default'的部分代码来改变吗? –