(self, image, label)
| 23 | tf.TensorSpec([None], tf.int32, 'label')] |
| 24 | |
| 25 | def build_graph(self, image, label): |
| 26 | image = image / 128.0 - 1 |
| 27 | |
| 28 | with argscope(Conv2D, activation=BNReLU, use_bias=False): |
| 29 | logits = (LinearWrap(image) |
| 30 | .Conv2D('conv1', 24, 5, padding='VALID') |
| 31 | .MaxPooling('pool1', 2, padding='SAME') |
| 32 | .Conv2D('conv2', 32, 3, padding='VALID') |
| 33 | .Conv2D('conv3', 32, 3, padding='VALID') |
| 34 | .MaxPooling('pool2', 2, padding='SAME') |
| 35 | .Conv2D('conv4', 64, 3, padding='VALID') |
| 36 | .Dropout('drop', rate=0.5) |
| 37 | .FullyConnected('fc0', 512, |
| 38 | bias_initializer=tf.constant_initializer(0.1), |
| 39 | activation=tf.nn.relu) |
| 40 | .FullyConnected('linear', units=10)()) |
| 41 | tf.nn.softmax(logits, name='output') |
| 42 | |
| 43 | accuracy = tf.cast(tf.nn.in_top_k(logits, label, 1), tf.float32) |
| 44 | add_moving_summary(tf.reduce_mean(accuracy, name='accuracy')) |
| 45 | |
| 46 | cost = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits, labels=label) |
| 47 | cost = tf.reduce_mean(cost, name='cross_entropy_loss') |
| 48 | |
| 49 | wd_cost = regularize_cost('fc.*/W', l2_regularizer(0.00001)) |
| 50 | add_moving_summary(cost, wd_cost) |
| 51 | |
| 52 | add_param_summary(('.*/W', ['histogram', 'rms'])) # monitor W |
| 53 | return tf.add_n([cost, wd_cost], name='cost') |
| 54 | |
| 55 | def optimizer(self): |
| 56 | lr = tf.train.exponential_decay( |
nothing calls this directly
no test coverage detected