2017-07-05 4 views
0

https://gist.github.com/Wermarter/466e9585579ef65927fa934fe4e0ffd4 Ici, j'essaie d'implémenter Variational AutoEncoder dans Tensorflow avec TFLearn.De manière inattendue, nécessaire pour donner une valeur d'entrée à un espace réservé non pertinent dans le graphique

Je compile les calculs pour l'apprentissage, l'encodage et la génération dans un grand graphique en self.training_model.session. Les self.generating_model et self.recognition_model partagent la même session que self.training_model.

Tout s'est bien passé lorsque j'ai exécuté le generating_model pour générer l'espace MNIST 2D Latent. Mais une erreur est apparue lorsque j'ai couru self.recognition_model pour encoder l'input_data donné, il m'a fallu donner une valeur d'entrée au self.train_data qui appartient au self.training_model.

est ici l'erreur complète:

Traceback (most recent call last): 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1039, in _do_call 
    return fn(*args) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1021, in _run_fn 
    status, run_metadata) 
    File "/home/wermarter/anaconda3/lib/python3.5/contextlib.py", line 66, in __exit__ 
    next(self.gen) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status 
    pywrap_tensorflow.TF_GetCode(status)) 
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'train_data/X' with dtype float 
    [[Node: train_data/X = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/gpu:0"]()]] 
    [[Node: add_5/_47 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_8_add_5", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]] 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "/home/wermarter/Desktop/vae.py", line 178, in <module> 
    main() 
    File "/home/wermarter/Desktop/vae.py", line 172, in main 
    vae.img_transition(trainX[4], trainX[100]) 
    File "/home/wermarter/Desktop/vae.py", line 130, in img_transition 
    enc_A = self.encode(A)[0] 
    File "/home/wermarter/Desktop/vae.py", line 121, in encode 
    return self.recognition_model.predict({self.input_data: input_data}) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tflearn/models/dnn.py", line 257, in predict 
    return self.predictor.predict(feed_dict) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tflearn/helpers/evaluator.py", line 69, in predict 
    return self.session.run(self.tensors[0], feed_dict=feed_dict) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 778, in run 
    run_metadata_ptr) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 982, in _run 
    feed_dict_string, options, run_metadata) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1032, in _do_run 
    target_list, options, run_metadata) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1052, in _do_call 
    raise type(e)(node_def, op, message) 
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'train_data/X' with dtype float 
    [[Node: train_data/X = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/gpu:0"]()]] 
    [[Node: add_5/_47 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_8_add_5", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]] 

Caused by op 'train_data/X', defined at: 
    File "/home/wermarter/Desktop/vae.py", line 178, in <module> 
    main() 
    File "/home/wermarter/Desktop/vae.py", line 169, in main 
    vae = VAE() 
    File "/home/wermarter/Desktop/vae.py", line 28, in __init__ 
    self._build_training_model() 
    File "/home/wermarter/Desktop/vae.py", line 78, in _build_training_model 
    self.train_data = tflearn.input_data(shape=[None, *self.img_shape], name='train_data') 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tflearn/layers/core.py", line 81, in input_data 
    placeholder = tf.placeholder(shape=shape, dtype=dtype, name="X") 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/array_ops.py", line 1507, in placeholder 
    name=name) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1997, in _placeholder 
    name=name) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op 
    op_def=op_def) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2336, in create_op 
    original_op=self._default_original_op, op_def=op_def) 
    File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1228, in __init__ 
    self._traceback = _extract_stack() 

InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'train_data/X' with dtype float 
    [[Node: train_data/X = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/gpu:0"]()]] 
    [[Node: add_5/_47 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_8_add_5", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]] 

Répondre

0

Ceci est une erreur spécifique de code. Mon self.recognition_model est actuellement lié à l'espace réservé self.train_data à self.curr_batch_size dans self._sample_z(). Ma solution consiste à relier self.curr_batch_size à la taille de self.input_data.

C'est tout. Happy Coding