Browse Source

hyperparameter tuning

James Jeon 2 years ago
parent
commit
22e5bc3168
3 changed files with 13 additions and 15 deletions
  1. 8
    8
      model.py
  2. 2
    4
      params.py
  3. 3
    3
      train.py

+ 8
- 8
model.py View File

@@ -11,8 +11,8 @@ keep_prob = tf.placeholder(tf.float32)
11 11
 x_image = tf.reshape(x, [-1, params.network_height, params.img_width, params.img_channels])
12 12
 
13 13
 # Conv Layer # 1
14
-network = tf.layers.conv2d(x_image, filters=96, kernel_size = (11,11), strides=(4,4), 
15
-	padding='same', activation=tf.nn.relu, use_bias=True,name="conv_1")
14
+network = tf.layers.conv2d(x_image, filters=64, kernel_size = (7,7), strides=(2,2), 
15
+	padding='same', activation=tf.nn.relu, use_bias=False,name="conv_1")
16 16
 if print_layer:
17 17
 	print(network)
18 18
 network = tf.layers.max_pooling2d(network, pool_size=(3,3), strides=2, padding='same', 
@@ -25,8 +25,8 @@ if print_layer:
25 25
 
26 26
 # Conv Layer #2
27 27
 
28
-network = tf.layers.conv2d(network, filters=256, kernel_size = (5,5), strides=(1,1), 
29
-	padding='same', activation=tf.nn.relu, use_bias=True,name="conv_2")
28
+network = tf.layers.conv2d(network, filters=128, kernel_size = (5,5), strides=(1,1), 
29
+	padding='same', activation=tf.nn.relu, use_bias=False,name="conv_2")
30 30
 if print_layer:
31 31
 	print(network)
32 32
 network = tf.layers.max_pooling2d(network, pool_size=(3,3), strides=2, padding='same', 
@@ -39,7 +39,7 @@ if print_layer:
39 39
 
40 40
 # Conv Layer #3
41 41
 
42
-network = tf.layers.conv2d(network, filters=384, kernel_size = (3,3), strides=(1,1), 
42
+network = tf.layers.conv2d(network, filters=256, kernel_size = (3,3), strides=(1,1), 
43 43
 	padding='same', activation=tf.nn.relu, use_bias=True,name="conv_3_1")
44 44
 if print_layer:
45 45
 	print(network)
@@ -47,8 +47,8 @@ network = tf.layers.conv2d(network, filters=256, kernel_size = (3,3), strides=(1
47 47
 	padding='same', activation=tf.nn.relu, use_bias=True,name="conv_3_2")
48 48
 if print_layer:
49 49
 	print(network)
50
-network = tf.layers.conv2d(network, filters=32, kernel_size = (3,3), strides=(1,1), 
51
-	padding='same', activation=tf.nn.relu, use_bias=True,name="conv_3_3")
50
+network = tf.layers.conv2d(network, filters=16, kernel_size = (3,3), strides=(1,1), 
51
+	padding='same', activation=tf.nn.relu, use_bias=False,name="conv_3_3")
52 52
 if print_layer:
53 53
 	print(network)
54 54
 network = tf.layers.max_pooling2d(network, pool_size=(3,3), strides=2, padding='same', 
@@ -60,7 +60,7 @@ if print_layer:
60 60
 	print(network)
61 61
 
62 62
 # Flatten
63
-network = tf.reshape(network, [-1, 768], name="flatten")
63
+network = tf.reshape(network, [-1, 1280], name="flatten")
64 64
 if print_layer:
65 65
 	print(network)
66 66
 

+ 2
- 4
params.py View File

@@ -4,7 +4,5 @@ img_height = 66
4 4
 img_width = 256
5 5
 img_channels = 1
6 6
 network_height = 66
7
-batch = 32
8
-epoch = 5
9
-write_summary = True
10
-save_dir = os.path.abspath('models')
7
+batch = 16
8
+epoch = 15

+ 3
- 3
train.py View File

@@ -12,11 +12,11 @@ from get_val_data import val_data
12 12
 from get_train_data import train_data
13 13
 
14 14
 sess = tf.InteractiveSession()
15
+LR = 1e-4
15 16
 
16 17
 # loss = tf.losses.absolute_difference(model.y_, model.y)
17 18
 loss = tf.losses.mean_squared_error(model.y_, model.y)
18
-train = tf.train.AdamOptimizer(1e-4).minimize(loss)
19
-acc = tf.reduce_mean(tf.abs(tf.div(tf.subtract(model.y_, model.y), model.y)))
19
+train = tf.train.AdamOptimizer(LR).minimize(loss)
20 20
 
21 21
 saver = tf.train.Saver()
22 22
 
@@ -51,7 +51,7 @@ for i in range(params.epoch):
51 51
 
52 52
 				print ("epoch {} of {}, batch {} of {}, train loss {}, val loss {}".format(i, params.epoch,iteration,batch_iteration,t_loss, v_loss))
53 53
 
54
-	model_name = "./weight/MSE_without-0_{}.model".format(i)
54
+	model_name = "./weight/SSC_epoch_{}_LR_{}.model".format(i,LR)
55 55
 	save_path = saver.save(sess, model_name)
56 56
 
57 57
 

Loading…
Cancel
Save