1

Here's my code https://gist.github.com/Wermarter/318756a2f4cda35ebb178a932e1f8c38

I'm trying to implement VAE with TFLearn but the compiler said:

Traceback (most recent call last):
  File "/home/wermarter/Desktop/ChienVAE_RawTF.py", line 107, in <module>
    main()
  File "/home/wermarter/Desktop/ChienVAE_RawTF.py", line 101, in main
    vae = VAE()
  File "/home/wermarter/Desktop/ChienVAE_RawTF.py", line 26, in __init__
    self._build_graph()
  File "/home/wermarter/Desktop/ChienVAE_RawTF.py", line 67, in _build_graph
    self.training_model = tflearn.Trainer(train_ops=trainop, tensorboard_dir=TENSORBOARD_DIR)
  File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tflearn/helpers/trainer.py", line 131, in __init__
    clip_gradients)
  File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tflearn/helpers/trainer.py", line 651, in initialize_training_ops
    ema_num_updates=self.training_steps)
  File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tflearn/summaries.py", line 239, in add_loss_summaries
    loss_averages_op = loss_averages.apply([loss] + other_losses)
  File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/training/moving_averages.py", line 375, in apply
    colocate_with_primary=(var.op.type in ["Variable", "VariableV2"]))
  File "/home/wermarter/anaconda3/lib/python3.5/site-packages/tensorflow/python/training/slot_creator.py", line 169, in create_zeros_slot
    else array_ops.shape(primary.initialized_value()))
AttributeError: 'Tensor' object has no attribute 'initialized_value'

I've tried running some examples on github and they worked fine, I think this is not about bugs in Tensorflow or TFlearn

2
  • What TF version do you have? I've run your script and I see "ValueError: Cannot convert a partially known TensorShape to a Tensor: (?, 784)" I have 1.0.1 Commented Jun 22, 2017 at 4:41
  • @S.Stas I'm using TF 1.2.0. And when running on 1.0.1 it did show up that ValueError (?, 784) Commented Jun 22, 2017 at 8:00

1 Answer 1

3

The error above is somewhat vague in TF 1.2.0 but in TF 1.0.1 it is much clearer

ValueError: Cannot convert a partially known TensorShape to a Tensor: (?, 784)

This is a problem with my tf.random_normal where TF cannot understand the input shape (the batch size is not specify). So I dealt with this problem by create another number:

batch_size = tf.shape(z_mean)[0]

eps = tf.random_normal((batch_size, self.latent_dim))

instead of:

eps = tf.random_normal(tf.shape(z_mean)) <==== Error

I tested this non-error version with TF 1.2.0 and it worked great https://gist.github.com/Wermarter/9e0e29ee80adaa0f7af17b72d8e58a67

Click to see the result of 2D MNIST latent space

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.