La variable de marcador de posición TensorFlow para entero o booleano no está funcionando

Estoy utilizando el siguiente fragmento de código en TensorFlow para extraer datos de forma condicional de una fuente u otra:

if __name__ == '__main__': with tf.device("/gpu:0"): with tf.Graph().as_default(): with tf.variable_scope("cifar_conv_model"): is_train = tf.placeholder(tf.int32) # placeholder for whether to pull from train or val data keep_prob = tf.placeholder(tf.float32) # dropout probability x, y = tf.cond(tf.equal(is_train, tf.constant(1, dtype=tf.int32)), distorted_inputs, inputs) output = inference(x, keep_prob) cost = loss(output, y) global_step = tf.Variable(0, name='global_step', trainable=False) train_op = training(cost, global_step) eval_op = evaluate(output, y) summary_op = tf.merge_all_summaries() saver = tf.train.Saver() summary_writer = tf.train.SummaryWriter("conv_cifar_logs/", graph_def=sess.graph_def) init_op = tf.initialize_all_variables() sess = tf.Session() sess.run(init_op) tf.train.start_queue_runners(sess=sess) # Training cycle for epoch in range(training_epochs): avg_cost = 0. total_batch = int(cifar10_input.NUM_EXAMPLES_PER_EPOCH_FOR_TRAIN/batch_size) # Loop over all batches for i in range(total_batch): # Fit training using batch data _, new_cost = sess.run([train_op, cost], feed_dict={is_train: 1, keep_prob: 0.5}) # Compute average loss avg_cost += new_cost/total_batch print "Epoch %d, minibatch %d of %d. Average cost = %0.4f." %(epoch, i, total_batch, avg_cost) 

Sigo obteniendo el vómito de error a medida que los hilos se desvanecen, pero el tema recurrente es el siguiente error:

 InvalidArgumentError: You must feed a value for placeholder tensor 'cifar_conv_model/Placeholder' with dtype int32 [[Node: cifar_conv_model/Placeholder = Placeholder[dtype=DT_INT32, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]] [[Node: cifar_conv_model/Placeholder/_151 = _HostRecv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_407_cifar_conv_model/Placeholder", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"]()]] Caused by op u'cifar_conv_model/Placeholder', defined at: File "convnet_cifar.py", line 134, in  is_train = tf.placeholder(tf.int32) # placeholder for whether to pull from train or val data File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 743, in placeholder name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 607, in _placeholder name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/op_def_library.py", line 655, in apply_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2040, in create_op original_op=self._default_original_op, op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1087, in __init__ self._traceback = _extract_stack() 

Cualquier ayuda sería muy apreciada!

Una solución se menciona aquí: http://andyljones.tumblr.com/ .

is_train = tf.placeholder(tf.int32) cambiar su marcador de posición is_train = tf.placeholder(tf.int32) para una tf.Variable: is_train = tf.Variable(True, name='training') . Así podrá iniciar su llamada en sess.run (tf.initialize_all_variables ()) antes de realizar una llamada también tf.train.start_queue_runners(sess=sess) .