i'm trying implement answer 2 given following question on stackoverflow: how set layer-wise learning rate in tensorflow? seek use specific learning rate first 2 layers , rate 10 times less third , final layer.
these weights:
weights = { # 9x9 conv, 1 input, 64 output feature maps 'wc1': tf.variable(tf.random_normal([9, 9, 1, 64])), # 1x1 conv, 64 inputs, 32 output feature maps 'wc2': tf.variable(tf.random_normal([1, 1, 64, 32])), # 5x5 conv, 32 inputs, 32 output feature maps 'wc3': tf.variable(tf.random_normal([5, 5, 32, 1])) #'wc3': tf.variable(tf.random_normal([33*33*32, 33*33])) } biases = { 'bc1': tf.variable(tf.random_normal([64])), 'bc2': tf.variable(tf.random_normal([32])), 'bc3': tf.variable(tf.random_normal([1])) }
and implementation follows:
self.opt = tf.train.gradientdescentoptimizer(learning_rate=learning_rate) self.grads_and_vars = self.opt.compute_gradients(self.cost, [ self.weights['wc1'], self.biases['bc1'], self.weights['wc2'], self.biases['bc2'], self.weights['wc3'], self.biases['bc3'] ]) # apply gradients train_op = self.opt.apply_gradients([self.grads_and_vars[0], self.grads_and_vars[1], self.grads_and_vars[2], self.grads_and_vars[3], (self.grads_and_vars[4]/10, self.weights['wc3']), (self.grads_and_vars[5]/10, self.biases['bc3'])], global_step=self.global_step)
unfortunately, following error when running code pertains train_op operator (apply_gradients):
valueerror: shapes must equal rank, 4 , 5 'gradientdescent/update_variable_2/applygradientdescent' (op: 'applygradientdescent') input shapes: [5,5,32,1], [], [20,5,5,32,1].
i cannot understand tensor shape [20,5,5,32,1] since expecting [5,5,32,1] tensor weights. missing?
Comments
Post a Comment