backy 0.2.1

  • Installing
  • Versions
  • 16


Backy is a neural network which is using the backpropagation algorithm. (Written in Googles Dart). Please report all errors you can find to me.

How to

The Neuron The neuron defines how the output is computed and in what range...

The Neural Network:

It can be instanciated with any number of layer dimensions. For example: [2, 3, 1] which produces a net with 3 layers. The input layer has two inputs and the output layer has 1 output neuron. The hidden layer has 3 neurons.

Train the network

Use the "train"-method to tell the net what you expect from a certain input. net.train(<input>, <expected>);

e.g. train an XOR network:

  net.train([-1, -1], [ 1]);
  net.train([-1,  1], [-1]);
  net.train([ 1, -1], [-1]);
  net.train([ 1,  1], [ 1]);

Use the Network

Once the network is trained, you can use it and it will return the output:

<expected> = net.use(<input>);

print(net.use([-1, 1])); // prints probably: [-.9988, .9988]

A working example:

The network needs usually many trainingsteps in orderto find the right weights and therefore the solution. Use the trainer in order to train backy more comfortably.

  1. Imagine the trainer as a personal trainer for a student.
  2. You tell the trainer what he should train the student.
  3. And he will repeat the training until the student produces the expected answers, or until a maximum of trainingrounds has been exceeded.
// 1.
  var neuron  = new TanHNeuron(); // returnes floatingpoint values between -1 and 1
  var student = new Backy([2, 2, 1], neuron);
  var trainer = new Trainer(backy: student, maximumReapeatingCycle: 200, precision: .1);

// 2. Add the pattern whcih the network should learn
  trainer.addTrainingCase([-1,-1], [-1]);
  trainer.addTrainingCase([-1, 1], [-1]);
  trainer.addTrainingCase([ 1,-1], [-1]);
  trainer.addTrainingCase([ 1, 1], [ 1]);

// 3. train all the traininCases up to 300 times and be satisfied with a precision of .1
  print(trainer.trainOnlineSets()); // prints number loops it took to learn all trainingcases

// 4. After that you can use the neural network
  print(student.use([-1, 1]));
  print(student.use([ 1,-1]));
  print(student.use([ 1, 1]));

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  backy: ^0.2.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:backy/backy.dart';
Version Uploaded Documentation Archive
0.2.1 Sep 1, 2013 Go to the documentation of backy 0.2.1 Download backy 0.2.1 archive
0.2.0 Sep 1, 2013 Go to the documentation of backy 0.2.0 Download backy 0.2.0 archive
0.1.0 Aug 24, 2013 Go to the documentation of backy 0.1.0 Download backy 0.1.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Health issues and suggestions

Fix lib/neuron.dart. (-57.81 points)

Analysis of lib/neuron.dart failed with 3 errors:

line 3 col 47: The getter 'E' isn't defined for the class 'Math'.

line 4 col 52: The getter 'E' isn't defined for the class 'Math'.

line 41 col 62: The getter 'E' isn't defined for the class 'Math'.

Document public APIs (-10 points)

103 out of 103 API elements (library, class, field or method) have no adequate dartdoc content. Good documentation improves code readability and discoverability through search.

Format lib/backy.dart.

Run dartfmt to format lib/backy.dart.

Format lib/layer.dart.

Run dartfmt to format lib/layer.dart.

Format lib/trainer.dart.

Run dartfmt to format lib/trainer.dart.

Format lib/weight.dart.

Run dartfmt to format lib/weight.dart.

Maintenance issues and suggestions

Add SDK constraint in pubspec.yaml. (-50 points)

For information about setting SDK constraint, please see

Package is too old. (-100 points)

The package was released more than two years ago.

Maintain (-20 points)

Changelog entries help clients to follow the progress in your code.

Homepage is not helpful. (-10 points)

Update the homepage property: create a website about the package or use the source repository URL.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use backy.dart.

The description is too long. (-10 points)

Search engines will display only the first part of the description. Try to keep it under 180 characters.