0
I am studying AI with tensorflow, but am facing the following error:
Valueerror: Variable generator/Dense/kernel does not exist, or was not created with Tf.get_variable(). Did you Mean to set reuse=Tf.AUTO_REUSE in Varscope?
Would anyone know how to solve or even the cause of it?
Follows the code:
import numpy as np
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import matplotlib.pyplot as plt
tf.reset_default_graph()
mnist = input_data.read_data_sets(r"C:\Users\mbeat\Desktop\Eduardo\cods\Estudos\Udemy\Redes Neurais\Modulo 3\mnist_data", one_hot=True)
imagem1 = np.arange(0, 784).reshape(28,28)
imagem2 = np.random.normal(size=784).reshape(28,28)
ruido_ph = tf.placeholder(tf.float32, [None, 100])
def gerador(ruido, reuse=None):
with tf.variable_scope("gerador", reuse=reuse):
#estrutura: 100 -> 128 -> 128 -> 784
camada_oculta1 = tf.nn.relu(tf.layers.dense(inputs=ruido, units=128))
camada_oculta2 = tf.nn.relu(tf.layers.dense(inputs=camada_oculta1, units=128))
camada_saida = tf.layers.dense(inputs=camada_oculta2, units=784, activation=tf.nn.tanh)
return camada_saida
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
ruido_teste = np.random.uniform(-1, 1, size=(1,100))
amostra = sess.run(gerador(ruido_ph, True), feed_dict={ruido_ph:ruido_teste})
print(amostra)