输出结果
设计思路
核心代码
def getnet():
data = mx.symbol.Variable('data')
label = mx.symbol.Variable('softmax_label')
conv1 = mx.symbol.Convolution(data=data, kernel=(5,5), num_filter=32)
pool1 = mx.symbol.Pooling(data=conv1, pool_type="max", kernel=(2,2), stride=(1, 1))
relu1 = mx.symbol.Activation(data=pool1, act_type="relu")
conv2 = mx.symbol.Convolution(data=relu1, kernel=(5,5), num_filter=32)
pool2 = mx.symbol.Pooling(data=conv2, pool_type="avg", kernel=(2,2), stride=(1, 1))
relu2 = mx.symbol.Activation(data=pool2, act_type="relu")
flatten = mx.symbol.Flatten(data = relu2)
fc1 = mx.symbol.FullyConnected(data = flatten, num_hidden = 120)
fc21 = mx.symbol.FullyConnected(data = fc1, num_hidden = 65)
fc22 = mx.symbol.FullyConnected(data = fc1, num_hidden = 65)
fc23 = mx.symbol.FullyConnected(data = fc1, num_hidden = 65)
fc24 = mx.symbol.FullyConnected(data = fc1, num_hidden = 65)
fc25 = mx.symbol.FullyConnected(data = fc1, num_hidden = 65)
fc26 = mx.symbol.FullyConnected(data = fc1, num_hidden = 65)
fc27 = mx.symbol.FullyConnected(data = fc1, num_hidden = 65)
fc2 = mx.symbol.Concat(*[fc21, fc22, fc23, fc24,fc25,fc26,fc27], dim = 0)
return mx.symbol.SoftmaxOutput(data = fc2, name = "softmax")
sym = getnet()
executor = sym.simple_bind(ctx = mx.cpu(), **input_shapes)