(self, image, label)
| 33 | tf.TensorSpec([None], tf.int32, 'label')] |
| 34 | |
| 35 | def build_graph(self, image, label): |
| 36 | blocks = CFG[DEPTH] |
| 37 | |
| 38 | bottleneck = functools.partial(resnet_bottleneck, stride_first=True) |
| 39 | |
| 40 | # tensorflow with padding=SAME will by default pad [2,3] here. |
| 41 | # but caffe conv with stride will pad [3,2] |
| 42 | image = tf.pad(image, [[0, 0], [3, 2], [3, 2], [0, 0]]) |
| 43 | image = tf.transpose(image, [0, 3, 1, 2]) |
| 44 | with argscope([Conv2D, MaxPooling, GlobalAvgPooling, BatchNorm], |
| 45 | data_format='channels_first'), \ |
| 46 | argscope(Conv2D, use_bias=False): |
| 47 | logits = (LinearWrap(image) |
| 48 | .Conv2D('conv0', 64, 7, strides=2, activation=BNReLU, padding='VALID') |
| 49 | .MaxPooling('pool0', 3, strides=2, padding='SAME') |
| 50 | .apply2(resnet_group, 'group0', bottleneck, 64, blocks[0], 1) |
| 51 | .apply2(resnet_group, 'group1', bottleneck, 128, blocks[1], 2) |
| 52 | .apply2(resnet_group, 'group2', bottleneck, 256, blocks[2], 2) |
| 53 | .apply2(resnet_group, 'group3', bottleneck, 512, blocks[3], 2) |
| 54 | .GlobalAvgPooling('gap') |
| 55 | .FullyConnected('linear', 1000)()) |
| 56 | tf.nn.softmax(logits, name='prob') |
| 57 | ImageNetModel.compute_loss_and_error(logits, label) |
| 58 | |
| 59 | |
| 60 | def get_inference_augmentor(): |
nothing calls this directly
no test coverage detected