Computer Vision News - March 2017

Computer Vision News Tool 13 We have only one data named data, and one label, with the name softmax_label. The following will initialize the network: Modules provide high-level APIs for training, predicting and evaluating. To fit a module, simply call the fit function with some DataIters. To predict with a module, simply call predict() with a DataIter. It will collect and return all the prediction results. You can read more about this basic example here . Tool import mxnet as mx from data_iter import SyntheticData net = mx.sym.Variable('data') net = mx.sym.FullyConnected(net, name='fc1', num_hidden=64) net = mx.sym.Activation(net, name='relu1', act_type="relu") net = mx.sym.FullyConnected(net, name='fc2', num_hidden=10) net = mx.sym.SoftmaxOutput(net, name='softmax') # synthetic 10 classes dataset with 128 dimension data = SyntheticData(10, 128) mx.viz.plot_network(net) mod = mx.mod.Module(symbol=net, context=mx.cpu(), data_names=['data'], label_names=['softmax_label']) batch_size=32 mod.fit(data.get_iter(batch_size), eval_data=data.get_iter(batch_size), optimizer='sgd', optimizer_params={'learning_rate':0.1}, eval_metric='acc', num_epoch=5) y = mod.predict(data.get_iter(batch_size)) 'shape of predict: %s' % (y.shape,)

RkJQdWJsaXNoZXIy NTc3NzU=