Starting with the linear classifier

First of all, we will try to create a simple one-layer neural network to set the baseline. We will start with mx.chain and define our network using the Symbolic API. We will use the FullyConnected, Activation, and SoftmaxOutput layers. When the architecture is defined, we will create a model by calling mx.FeedForward. The primary reason for running mx.FeedForward is to set whether the network will run on CPU or GPU:

arch = @mx.chain mx.Variable(:data) =>  mx.FullyConnected(num_hidden=128) =>  mx.Activation(name=:relu1, act_type=:relu) =>  mx.FullyConnected(num_hidden=10) =>  mx.SoftmaxOutput(mx.Variable(:label))nnet = mx.FeedForward(arch, context = mx.cpu())mx.fit(nnet, mx.ADAM(), train_data_provider, eval_data ...

Get Hands-On Computer Vision with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.