mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

[API docs submission] LinearRegressionOutput

Open rongali-naidu opened this issue 9 years ago • 2 comments

Description: It is used to add output layer based on linear activation to the neural network. It computes and optimizes for squared loss.

Parameters:

    data (NDArray / Symbol) – Input data to the function.  
    label (NDArray / Symbol) – Input label to the function.
    grad_scale (float, optional, default=1) – Scale the gradient by a float factor
    out (NDArray / Symbol , optional) – The output NDArray to hold the result.

Returns:

out – The output of this function.
Return type:	 NDArray / Symbol or list of NDArrays

Note:

Use the LinearRegressionOutput as the final output layer of a net.

By default, gradients of this loss function are scaled by factor 1/n, where n is the number of training examples. The parameter grad_scale can be used to change this scale to grad_scale/n.

Defined in src/operator/regression_output.cc:L45

Example: both Symbol and NDArray provide these operations. Below example uses Symbol to illustrate this functionality since the required neural network is constructed using Symbol.

	trainingX=[Input Data Array]
	trainingY=[Output Label Array]

	X = mx.sym.Variable('data')
	net = mx.sym.FullyConnected(data=X, name='fc1', num_hidden=20)
	net = mx.sym.Activation(data=net, name='relu1', act_type="relu")
	net = mx.sym.FullyConnected(data=net, name='fc2', num_hidden=5)

	finalnetwork = mx.symbol.LinearRegressionOutput(data=net, name='softmax') # This defines output layer


	model = mx.model.FeedForward(ctx=mx.cpu(),
			symbol             = finalnetwork,
			num_epoch          = 65,
			learning_rate      = 0.001,
			wd                 = 0.00001,
			momentum           = 0.9)

	model.fit(X=trainingX, y=trainingY)

rongali-naidu avatar May 03 '17 09:05 rongali-naidu

@madjam @nswamy

domdivakaruni avatar May 08 '17 15:05 domdivakaruni

This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!

yajiedesign avatar Sep 30 '17 11:09 yajiedesign