Data Set
In this example, a sine function will be approximated from noisy measurements. This is an example for nonlinear regression. To run this example, you have to install matplotlib. It is a plotting library for Python.
Code
16 print(
"Matplotlib is required")
23 net.set_regularization(0.0, 0.0001, 0.0)
25 net.fully_connected_layer(10, Activation.LOGISTIC)
26 net.fully_connected_layer(10, Activation.LOGISTIC)
27 net.output_layer(1, Activation.LINEAR)
30 X = numpy.linspace(0, 2*numpy.pi, 500)[:, numpy.newaxis]
31 T = numpy.sin(X) + numpy.random.randn(*X.shape) * 0.1
32 dataset = DataSet(X, T)
34 Log.info(
"Using %d samples with %d inputs and %d outputs"
35 % (dataset.samples(), dataset.inputs(), dataset.outputs()))
39 "maximal_iterations": 50,
40 "minimal_value_differences": 1e-8
43 lma.optimize(net, dataset)
49 pylab.plot(X, T,
".", label=
"Data Set")
50 pylab.plot(X, Y, label=
"Prediction", linewidth=3)