MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / get_logits

Method get_logits

examples/ImageNetModels/alexnet.py:33–63  ·  view source on GitHub ↗
(self, image)

Source from the content-addressed store, hash-verified

31 data_format = 'NHWC' # LRN only supports NHWC
32
33 def get_logits(self, image):
34 gauss_init = tf.random_normal_initializer(stddev=0.01)
35 with argscope(Conv2D,
36 kernel_initializer=tf.variance_scaling_initializer(scale=2.)), \
37 argscope([Conv2D, FullyConnected], activation=tf.nn.relu), \
38 argscope([Conv2D, MaxPooling], data_format='channels_last'):
39 # necessary padding to get 55x55 after conv1
40 image = tf.pad(image, [[0, 0], [2, 2], [2, 2], [0, 0]])
41 l = Conv2D('conv1', image, filters=96, kernel_size=11, strides=4, padding='VALID')
42 # size: 55
43 visualize_conv1_weights(l.variables.W)
44 l = tf.nn.lrn(l, 2, bias=1.0, alpha=2e-5, beta=0.75, name='norm1')
45 l = MaxPooling('pool1', l, 3, strides=2, padding='VALID')
46 # 27
47 l = Conv2D('conv2', l, filters=256, kernel_size=5, split=2)
48 l = tf.nn.lrn(l, 2, bias=1.0, alpha=2e-5, beta=0.75, name='norm2')
49 l = MaxPooling('pool2', l, 3, strides=2, padding='VALID')
50 # 13
51 l = Conv2D('conv3', l, filters=384, kernel_size=3)
52 l = Conv2D('conv4', l, filters=384, kernel_size=3, split=2)
53 l = Conv2D('conv5', l, filters=256, kernel_size=3, split=2)
54 l = MaxPooling('pool3', l, 3, strides=2, padding='VALID')
55
56 l = FullyConnected('fc6', l, 4096,
57 kernel_initializer=gauss_init,
58 bias_initializer=tf.ones_initializer())
59 l = Dropout(l, rate=0.5)
60 l = FullyConnected('fc7', l, 4096, kernel_initializer=gauss_init)
61 l = Dropout(l, rate=0.5)
62 logits = FullyConnected('fc8', l, 1000, kernel_initializer=gauss_init)
63 return logits
64
65
66def get_data(name, batch):

Callers

nothing calls this directly

Calls 6

argscopeFunction · 0.90
Conv2DFunction · 0.85
visualize_conv1_weightsFunction · 0.85
MaxPoolingFunction · 0.85
FullyConnectedFunction · 0.85
DropoutFunction · 0.85

Tested by

no test coverage detected