Closed deepkyu closed 1 year ago
Hello @kyumaze, it is true. It is not working. I guess something was changed in tensorflow since the development of the example.
I was able to make it work changing:
add:
import tensorflow as tf
add: (around line 170)
self.sess = tf.Session()
self.Q = NeuralNetwork(self.sess, "Q", None, False, False) # 2nd term: False to start training from scratch, use CHECKPOINT to load a checkpoint
self.Q_ = NeuralNetwork(self.sess, "Q_", self.Q, False, True)
class NeuralNetwork:
def __init__(self, sess, name, NetworkToCopy = None, RestoreFromFile = False, ReplayNetwork = False):
self.frame_res = 5 # Resolution of the input
self.nframes = 1 # Number of frames/channels of the input
NumberOfActions = 11 # Number of possible actions
learning_rate = 1e-4 # Learning Rate
# Placeholders for the input variables
#self.sess = tf.compat.v1.InteractiveSession()
self.sess = sess
self.name = name
self.phy = tf.placeholder(tf.float32, shape=[None, self.frame_res*self.nframes]) # Flattened last nf frames of the game
self.y = tf.placeholder(tf.float32, shape=[None, 1])
self.action = tf.placeholder(tf.float32, shape=[None, NumberOfActions])
with tf.variable_scope(self.name):
# Fully-connected layer 1
input_f1 = self.phy
fc1_num_neurons = 256
self.W_fc1 = tf.Variable(tf.random.truncated_normal([self.frame_res*self.nframes, fc1_num_neurons], stddev=0.01), name="W_fc1")
self.b_fc1 = tf.Variable(tf.constant(0.01, shape=[fc1_num_neurons]), name="b_fc1")
self.input_fc1_flat = tf.reshape(input_f1, [-1, self.frame_res*self.nframes])
self.out_fc1 = tf.nn.relu(tf.matmul(self.input_fc1_flat, self.W_fc1) + self.b_fc1)
# Fully-connected layer 2
fc2_num_neurons = 256
self.W_fc2 = tf.Variable(tf.random.truncated_normal([fc1_num_neurons, fc2_num_neurons], stddev=0.01), name="W_fc2")
self.b_fc2 = tf.Variable(tf.constant(0.01, shape=[fc2_num_neurons]), name="b_fc2")
self.out_fc2 = tf.nn.relu(tf.matmul(self.out_fc1, self.W_fc2) + self.b_fc2)
# Output layer
out_layer1_input = self.out_fc2
out_layer1_n_outputs = NumberOfActions
self.W_ol1 = tf.Variable(tf.random.truncated_normal([fc2_num_neurons, out_layer1_n_outputs], stddev=0.01), name="W_ol1")
self.b_ol1 = tf.Variable(tf.constant(0.01, shape=[out_layer1_n_outputs]), name="b_ol1")
self.Q_theta = tf.matmul(out_layer1_input, self.W_ol1) + self.b_ol1
self.Q_action = tf.reduce_sum(tf.multiply(self.Q_theta, self.action), reduction_indices=1, keepdims=True)
Please check if you are able to run the example with these changes.
Regards.
Hello. We are trying to run an example code in the given repo for robots. Most codes with rule-based methods works. We have tested that
player_rulebased-(tc).py
,player_random-walk.py
, andplayer_skeleton.py
are working well. However, onlyplayer-deep-learning-train.py
does not work :(We checked whether tensorflow-gpu and cudatoolkit are installed in our python environment, and also there's no error message about cuda library and its path. All of three members in our team got same trouble. Here's the console message about this issue.
So, could I ask you for checking whether this code works (or not)? Thanks.