The neural network created by PyBrain is initialized with random numbers by default, and we need to train the network to adjust the parameters

Pybrain provides trainers to train neural networks. Trainers receive the created network and training set as parameters.

A classic training method is the backpropagation method

>>> from pybrain.supervised.trainers import BackpropTrainer
Copy the code
>>> net = buildNetwork(2, 3, 1, bias=True, hiddenclass=TanhLayer)
>>> trainer = BackpropTrainer(net, ds)
Copy the code

Ds is the data set created in the previous section

> > > trainer. Train () 0.31516384514375834Copy the code

\