Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evalute for CNN model #2

Open
yhgon opened this issue Feb 7, 2019 · 0 comments
Open

evalute for CNN model #2

yhgon opened this issue Feb 7, 2019 · 0 comments

Comments

@yhgon
Copy link

yhgon commented Feb 7, 2019

Dear @xujinfan

I want to reproduce The search space is 5 in convolutional layers, 25 in fully-connected layers for RCL,DEN and PGN.

plz comment for define target variable for evaluate function.

TODO, I made basic 5 CNN model with 2 CNN(5x5,32), (5x5,64) + 2 Maxpool + 1 FCN(1024) as below :
https://github.com/yhgon/Reinforced-Continual-Learning/blob/master/RCL_CNN.py#L53

with tf.Graph().as_default() as g:
    with tf.name_scope("before"):
	inputs = tf.placeholder(shape=(None, 784), dtype=tf.float32)
	y = tf.placeholder(shape=(None, 10), dtype=tf.float32)
	w1 = tf.Variable(tf.truncated_normal([5,5,1,32], stddev=0.1))
	b1 = tf.Variable(tf.constant(0.1, shape=(32,)))
	w2 = tf.Variable(tf.truncated_normal([5,5,32,64], stddev=0.1))
	b2 = tf.Variable(tf.constant(0.1, shape=(64,)))
	w3 = tf.Variable(tf.truncated_normal([2*2*64,1024], stddev=0.1))
	b3 = tf.Variable(tf.constant(0.1, shape=(1024, )))
	w4 = tf.Variable(tf.truncated_normal([1024,10], stddev=0.1))
	b4 = tf.Variable(tf.constant(0.1, shape=(10,)))
	## model
	inputs_shape= inputs.get_shape().as_list()
	print("DEBUG input_shape before:",inputs_shape)
	inputx=tf.reshape(inputs, shape=[-1,28,28,1]) # 28x28
	inputs_shape= inputx.get_shape().as_list()
	print("DEBUG input_shape after :",inputs_shape)
	conv1 = tf.nn.relu(tf.nn.conv2d(inputx, w1,    strides=[1,2,2,1], padding='SAME') + b1)
	conv1 = tf.nn.max_pool(conv1, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME')
	conv2 = tf.nn.relu(tf.nn.conv2d(conv1, w2,     strides=[1,2,2,1], padding='SAME') + b2)
	conv2 = tf.nn.max_pool(conv2, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME')
	conv2_shape = conv2.get_shape().as_list()
	print("DEBUG conv2_shape before :",conv2_shape)
	conv2 = tf.reshape(conv2, [-1, conv2_shape[1] * conv2_shape[2] * conv2_shape[3]])
	conv2_shape = conv2.get_shape().as_list()
	print("DEBUG conv2_shape after :",conv2_shape)
	fcn= tf.nn.relu(tf.matmul(conv2, w3) + b3)
	output3=tf.matmul(fcn, w4) + b4
	loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y, logits=output3)) + \
	       0.0001*(tf.nn.l2_loss(w1) + tf.nn.l2_loss(w2) + tf.nn.l2_loss(w3) + tf.nn.l2_loss(w4))

task 0 for initial training works well as below :

--batch_size 1024 --n_epochs 30 --n_tasks 10 --n_layers 2 --hidden_size 10 --num_layers 2 --max_trials 40 --actions_num 2
DEBUG : task0/10 IF
DEBUG input_shape before: [None, 784]
DEBUG input_shape after : [None, 28, 28, 1]
DEBUG conv2_shape before : [None, 2, 2, 64]
DEBUG conv2_shape after : [None, 256]

task 0/10  epoch 29  train_step 53248/55000
task 0/10  epoch 29  train_step 54272/55000
task 0/10  epoch 29  train_step 55296/55000
task 0/10 test accuracy: 0.9629999995231628 IF
task 1/10 trial 0/40 *********actions  for [13, 14] ELSE 


DEBUG :  0 (5, 1, 32)
DEBUG :  1 ()
DEBUG :  2 (5, 32, 64)
DEBUG :  3 ()
DEBUG :  4 (1024,)
DEBUG :  5 ()
DEBUG : TODO 

I wonder how to set action for 2d conv and range for var_list.

  • conv1 : 5x5 conv filter , 32
  • conv2 : 5x5 conv , 64
  • FCN : 1024

current actions for [13, 14] use (5,1,32) instead of (5x5,1,3) of (5x5,1,32)
IMHO, right behavior for taget would be control 32.

task 1/10 trial 0/40 *********actions  for  [13, 14] ELSE 
DEBUG :  0 (5, 1, 32)
DEBUG :  1 ()
DEBUG :  2 (5, 32, 64)
DEBUG :  3 ()
DEBUG :  4 (1024,)
DEBUG :  5 ()
DEBUG : TODO 

in FCN task1, var_list is below :

#DEBUG :  0 (312,)
#DEBUG :  1 ()
#DEBUG :  2 (128,)
#DEBUG :  3 ()
#DEBUG :  4 (10,)
#DEBUG :  5 ()  

how to control the target?
in your paper, do you also control conv filter size such as 3x3, 5x5, 1x1 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant