Issue of using DBN
skx300 opened this issue · comments
skx300 commented
I am trying to use your module in the scripts instead of the command line. Here I want to use the DBN.
When I run
import tensorflow as tf
from yadlt.models.boltzmann import dbn
from tensorflow.examples.tutorials.mnist import input_data
# load the data
mnist = input_data.read_data_sets("tensorflow_learning/MNIST_data/", one_hot = True)
x_train = mnist.train.images
y_train = mnist.train.labels
x_val = mnist.validation.images
y_val = mnist.validation.labels
# create a DBN
my_DBN = dbn.DeepBeliefNetwork(rbm_layers = [50, 30, 20],
finetune_loss_func = 'softmax_cross_entropy',
finetune_dropout = 1,
finetune_learning_rate = 0.001,
finetune_act_func = tf.nn.sigmoid,
finetune_num_epochs = 20,
finetune_batch_size = 20,
do_pretrain = True)
my_DBN.pretrain(x_train, x_val)
my_DBN.build_model(784, 10)
my_DBN._train_model(x_train, y_train, x_val, y_val)
The last line my_DBN._train_model(x_train, y_train, x_val, y_val)
gives the following error:
File "D:\Program Files\Anaconda3\lib\site-packages\yadlt\models\boltzmann\dbn.py", line 147, in _train_model
AttributeError: 'NoneType' object has no attribute 'run'
When I go back to the line 147 of dbn.py, that is
self.tf_session.run
By the way, I am not quite sure the scheme I used above is correct or not. Could you write a kind of script usage in the documentation?