MCPcopy
hub / github.com/tensorlayer/TensorLayer / model

Function model

examples/quantized_net/tutorial_ternaryweight_mnist_cnn.py:20–38  ·  view source on GitHub ↗
(inputs_shape, n_class=10)

Source from the content-addressed store, hash-verified

18
19
20def model(inputs_shape, n_class=10):
21 in_net = Input(inputs_shape, name='input')
22 net = TernaryConv2d(32, (5, 5), (1, 1), padding='SAME', b_init=None, name='bcnn1')(in_net)
23 net = MaxPool2d((2, 2), (2, 2), padding='SAME', name='pool1')(net)
24 net = BatchNorm(act=tl.act.htanh, name='bn1')(net)
25
26 net = TernaryConv2d(64, (5, 5), (1, 1), padding='SAME', b_init=None, name='bcnn2')(net)
27 net = MaxPool2d((2, 2), (2, 2), padding='SAME', name='pool2')(net)
28 net = BatchNorm(act=tl.act.htanh, name='bn2')(net)
29
30 net = Flatten('flatten')(net)
31 net = Dense(256, b_init=None, name='dense')(net)
32 net = BatchNorm(act=tl.act.htanh, name='bn3')(net)
33
34 net = TernaryDense(n_class, b_init=None, name='bout')(net)
35 net = BatchNorm(name='bno')(net)
36
37 net = Model(inputs=in_net, outputs=net, name='dorefanet')
38 return net
39
40
41def _train_step(network, X_batch, y_batch, cost, train_op=tf.optimizers.Adam(learning_rate=0.0001), acc=None):

Calls 8

InputFunction · 0.90
TernaryConv2dClass · 0.90
MaxPool2dClass · 0.90
BatchNormClass · 0.90
FlattenClass · 0.90
DenseClass · 0.90
TernaryDenseClass · 0.90
ModelClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…