deeplearning4d 0.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 57

deeplearning4d

Deep learning library for Dart based on Tensorflow Playground Neural Net implementation.

Example


import 'package:deeplearning4d/deeplearning4d.dart';
import 'dataset.dart';

List<List<Node>> network = null;
int iterations = 400;
List<Example2D> trainData = classifyTwoGaussData(500.0, 0.1);
List<Example2D> testData = classifyTwoGaussData( 50.0, 0.1);
double learningRate = 0.03;
double regularizationRate = 0.0;
double lossTrain = 0.0;
double lossTest = 0.0;
int batchSize = 30;


void main() {
  network = buildNetwork([2, 1, 1], Activations.RELU, Activations.TANH, RegularizationFunctions.L1, ["x", "y"], initZero: false);
  lossTrain = getLoss(network, trainData);
  lossTest = getLoss(network, testData);
  for (int i = 0; i < iterations; i ++) {
    oneStep();
  }
}

oneStep() {
  trainData.asMap().forEach((i, example2D) {
    List<double> input = constructInput(example2D.x, example2D.y);
    forwardProp(network, input);
    backProp(network, example2D.label, Errors.SQUARE);
    if ((i + 1) % batchSize == 0) {
      updateWeights(network, learningRate, regularizationRate);
    }
  });
// Compute the loss.
  lossTrain = getLoss(network, trainData);
  lossTest = getLoss(network, testData);
  print(lossTest.toString() + ',       ' + lossTrain.toString());
}


List<double> constructInput(double x, double y) {
  List<double> input = <double>[];
  input.add(x);
  input.add(y);
  return input;
}

double getLoss(List<List<Node>> network, List<Example2D> dataPoints) {
  double loss = 0.0;
  for (int i = 0; i < dataPoints.length; i++) {
    Example2D dataPoint = dataPoints[i];
    List<double> input = constructInput(dataPoint.x, dataPoint.y);
    double output = forwardProp(network, input);
    loss += Errors.SQUARE.error(output, dataPoint.label);
  }
  return loss / dataPoints.length;
}

Changelog

0.0.1

  • Initial version

example/deeplearning4d_example.dart

/* Copyright 2017. Marat Gubaidullin. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=============================================================================*/

import 'package:deeplearning4d/deeplearning4d.dart';
import 'dataset.dart';

List<List<Node>> network = null;
int iterations = 400;
List<Example2D> trainData = classifyTwoGaussData(500.0, 0.1);
List<Example2D> testData = classifyTwoGaussData( 50.0, 0.1);
double learningRate = 0.03;
double regularizationRate = 0.0;
double lossTrain = 0.0;
double lossTest = 0.0;
int batchSize = 30;


void main() {
  network = buildNetwork([2, 1, 1], Activations.RELU, Activations.TANH, RegularizationFunctions.L1, ["x", "y"], initZero: false);
  lossTrain = getLoss(network, trainData);
  lossTest = getLoss(network, testData);
  for (int i = 0; i < iterations; i ++) {
    oneStep();
  }
}

oneStep() {
  trainData.asMap().forEach((i, example2D) {
    List<double> input = constructInput(example2D.x, example2D.y);
    forwardProp(network, input);
    backProp(network, example2D.label, Errors.SQUARE);
    if ((i + 1) % batchSize == 0) {
      updateWeights(network, learningRate, regularizationRate);
    }
  });
// Compute the loss.
  lossTrain = getLoss(network, trainData);
  lossTest = getLoss(network, testData);
  print(lossTest.toString() + ',       ' + lossTrain.toString());
}


List<double> constructInput(double x, double y) {
  List<double> input = <double>[];
  input.add(x);
  input.add(y);
  return input;
}

double getLoss(List<List<Node>> network, List<Example2D> dataPoints) {
  double loss = 0.0;
  for (int i = 0; i < dataPoints.length; i++) {
    Example2D dataPoint = dataPoints[i];
    List<double> input = constructInput(dataPoint.x, dataPoint.y);
    double output = forwardProp(network, input);
    loss += Errors.SQUARE.error(output, dataPoint.label);
  }
  return loss / dataPoints.length;
}

1. Depend on it

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


dependencies:
  deeplearning4d: "^0.0.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 packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:deeplearning4d/deeplearning4d.dart';
        
Version Uploaded Documentation Archive
0.0.1 Aug 17, 2017 Go to the documentation of deeplearning4d 0.0.1 Download deeplearning4d 0.0.1 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
14 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
57

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:deeplearning4d/deeplearning4d.dart.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
Dev dependencies
test ^0.12.0