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

Function model

examples/quantized_net/tutorial_binarynet_mnist_cnn.py:20–42  ·  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 BNN, all the layers inputs are binary, with the exception of the first layer.
22 # ref: https://github.com/itayhubara/BinaryNet.tf/blob/master/models/BNN_cifar10.py
23 net_in = Input(inputs_shape, name='input')
24 net = BinaryConv2d(32, (5, 5), (1, 1), padding='SAME', b_init=None, name='bcnn1')(net_in)
25 net = MaxPool2d((2, 2), (2, 2), padding='SAME', name='pool1')(net)
26 net = BatchNorm(act=tl.act.htanh, name='bn1')(net)
27
28 net = Sign("sign1")(net)
29 net = BinaryConv2d(64, (5, 5), (1, 1), padding='SAME', b_init=None, name='bcnn2')(net)
30 net = MaxPool2d((2, 2), (2, 2), padding='SAME', name='pool2')(net)
31 net = BatchNorm(act=tl.act.htanh, name='bn2')(net)
32
33 net = Flatten('ft')(net)
34 net = Sign("sign2")(net)
35 net = BinaryDense(256, b_init=None, name='dense')(net)
36 net = BatchNorm(act=tl.act.htanh, name='bn3')(net)
37
38 net = Sign("sign3")(net)
39 net = BinaryDense(10, b_init=None, name='bout')(net)
40 net = BatchNorm(name='bno')(net)
41 net = Model(inputs=net_in, outputs=net, name='binarynet')
42 return net
43
44
45def _train_step(network, X_batch, y_batch, cost, train_op=tf.optimizers.Adam(learning_rate=0.0001), acc=None):

Callers 1

Calls 8

InputFunction · 0.90
BinaryConv2dClass · 0.90
MaxPool2dClass · 0.90
BatchNormClass · 0.90
SignClass · 0.90
FlattenClass · 0.90
BinaryDenseClass · 0.90
ModelClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…