tensorflow 0.0.0

  • README.md
  • Example
  • Installing
  • Versions
  • 6

Pub Build status Gitter License

Tensorflow API for the Dart programming language.

The goal of this project is to provide first-class support for machine learning and data science in Dart, a strongly-typed language that runs across all platforms.

This project is still in its early stages, but will grow very quickly.


This library uses native bindings, which (currently) are not easily distributed using Dart's Pub package manager.

Building the bindings, however, is easy and quick, as the build uses pre-built Tensorflow binaries, rather than re-building per user.


You'll need the following installed to run Tensorflow for Dart:

It's also strongly recommended to install the scripts command-line utility for Dart, which allows you to build the bindings in one step:

$ pub global activate scripts

Ensure that you have the path to Pub's global executables in your PATH environment variable.

On Windows, this is %APPDATA%\Pub\Cache\bin, whereas on UNIX-based systems, it should be ~/.pub-cache/bin.

Building as a Dependency

If you are using package:tensorflow as a dependency in a Dart project, then you will need to build the native bindings. This process is made simple the tool/build.dart file included with this project.

Using the scripts tool, you can build the bindings in your Pub cache, and they will be available to all Dart projects on your system:

$ scripts get && scripts clean

As an added bonus, the files generated by CMake are cached, which means you likely only ever have to build them once.

Building by Itself

If you are contributing to the project, you will certainly need to be able to build the project on the fly. Use the provided tool/build.dart script to build the project on-the-fly.

Basic Usage

Importing Graphs

This project supports loading and restoring models saved from other Tensorflow frontends, i.e. Python:

import 'package:tensorflow/tensorflow.dart' as tf;

void main() {
  // Using the `SavedModel` API:
  var model = new SavedModelBundle('example/saved_models');
  // Or, you can import from a `GraphDef` protocol buffer:
  var graph = new Graph.fromGraphDef(graphDef);
  graph['output'].run(feed: {'input': new Tensor.from('Hello, world!')});

Low Level API

package:tensorflow/tensorflow.dart supports the entire low-level Tensorflow API. This can be used to perform a variety of complex mathematical operations, and also be used to compose higher-level functionality.

import 'package:tensorflow/tensorflow.dart' as tf;

void main() {
    var shape = new tf.Shape(6, 6);
    var x = tf.getVariable(
      shape: shape,
      initializer: tf.randomUniform(
        dtype: tf.DataType.DT_FLOAT,
    x = tf.matMul(x, x);


import 'package:tensorflow/tensorflow.dart' as tf;

main() {
  var hello = tf.constant('Hello, Tensorflow!');
  var result = hello.run();
  print('Tensorflow version: ${tf.version}');
  print('Result: $result');

Use this package as a library

1. Depend on it

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

  tensorflow: ^0.0.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:tensorflow/tensorflow.dart';
Version Uploaded Documentation Archive
0.0.0 May 21, 2018 Go to the documentation of tensorflow 0.0.0 Download tensorflow 0.0.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.

We analyzed this package on Dec 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7


Detected platforms:

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.1.0.
 Because tensorflow depends on binary >=0.0.1 which requires SDK version >=1.8.0 <2.0.0, version solving failed.

Health suggestions

Format lib/src/dart/output.dart.

Run dartfmt to format lib/src/dart/output.dart.

Format lib/src/dart/saved_model_bundle.dart.

Run dartfmt to format lib/src/dart/saved_model_bundle.dart.

Format lib/src/proto/allocation_description.pb.dart.

Run dartfmt to format lib/src/proto/allocation_description.pb.dart.

Fix additional 84 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/proto/allocation_description.pbenum.dart (Run dartfmt to format lib/src/proto/allocation_description.pbenum.dart.)
  • lib/src/proto/allocation_description.pbjson.dart (Run dartfmt to format lib/src/proto/allocation_description.pbjson.dart.)
  • lib/src/proto/allocation_description.pbserver.dart (Run dartfmt to format lib/src/proto/allocation_description.pbserver.dart.)
  • lib/src/proto/any.pb.dart (Run dartfmt to format lib/src/proto/any.pb.dart.)
  • lib/src/proto/any.pbenum.dart (Run dartfmt to format lib/src/proto/any.pbenum.dart.)
  • lib/src/proto/any.pbjson.dart (Run dartfmt to format lib/src/proto/any.pbjson.dart.)
  • lib/src/proto/any.pbserver.dart (Run dartfmt to format lib/src/proto/any.pbserver.dart.)
  • lib/src/proto/attr_value.pb.dart (Run dartfmt to format lib/src/proto/attr_value.pb.dart.)
  • lib/src/proto/attr_value.pbenum.dart (Run dartfmt to format lib/src/proto/attr_value.pbenum.dart.)
  • lib/src/proto/attr_value.pbjson.dart (Run dartfmt to format lib/src/proto/attr_value.pbjson.dart.)
  • lib/src/proto/attr_value.pbserver.dart (Run dartfmt to format lib/src/proto/attr_value.pbserver.dart.)
  • lib/src/proto/cluster.pb.dart (Run dartfmt to format lib/src/proto/cluster.pb.dart.)
  • lib/src/proto/cluster.pbenum.dart (Run dartfmt to format lib/src/proto/cluster.pbenum.dart.)
  • lib/src/proto/cluster.pbjson.dart (Run dartfmt to format lib/src/proto/cluster.pbjson.dart.)
  • lib/src/proto/cluster.pbserver.dart (Run dartfmt to format lib/src/proto/cluster.pbserver.dart.)
  • lib/src/proto/config.pb.dart (Run dartfmt to format lib/src/proto/config.pb.dart.)
  • lib/src/proto/config.pbenum.dart (Run dartfmt to format lib/src/proto/config.pbenum.dart.)
  • lib/src/proto/config.pbjson.dart (Run dartfmt to format lib/src/proto/config.pbjson.dart.)
  • lib/src/proto/config.pbserver.dart (Run dartfmt to format lib/src/proto/config.pbserver.dart.)
  • lib/src/proto/cost_graph.pb.dart (Run dartfmt to format lib/src/proto/cost_graph.pb.dart.)
  • lib/src/proto/cost_graph.pbenum.dart (Run dartfmt to format lib/src/proto/cost_graph.pbenum.dart.)
  • lib/src/proto/cost_graph.pbjson.dart (Run dartfmt to format lib/src/proto/cost_graph.pbjson.dart.)
  • lib/src/proto/cost_graph.pbserver.dart (Run dartfmt to format lib/src/proto/cost_graph.pbserver.dart.)
  • lib/src/proto/debug.pb.dart (Run dartfmt to format lib/src/proto/debug.pb.dart.)
  • lib/src/proto/debug.pbenum.dart (Run dartfmt to format lib/src/proto/debug.pbenum.dart.)
  • lib/src/proto/debug.pbjson.dart (Run dartfmt to format lib/src/proto/debug.pbjson.dart.)
  • lib/src/proto/debug.pbserver.dart (Run dartfmt to format lib/src/proto/debug.pbserver.dart.)
  • lib/src/proto/function.pb.dart (Run dartfmt to format lib/src/proto/function.pb.dart.)
  • lib/src/proto/function.pbenum.dart (Run dartfmt to format lib/src/proto/function.pbenum.dart.)
  • lib/src/proto/function.pbjson.dart (Run dartfmt to format lib/src/proto/function.pbjson.dart.)
  • lib/src/proto/function.pbserver.dart (Run dartfmt to format lib/src/proto/function.pbserver.dart.)
  • lib/src/proto/graph.pb.dart (Run dartfmt to format lib/src/proto/graph.pb.dart.)
  • lib/src/proto/graph.pbenum.dart (Run dartfmt to format lib/src/proto/graph.pbenum.dart.)
  • lib/src/proto/graph.pbjson.dart (Run dartfmt to format lib/src/proto/graph.pbjson.dart.)
  • lib/src/proto/graph.pbserver.dart (Run dartfmt to format lib/src/proto/graph.pbserver.dart.)
  • lib/src/proto/meta_graph.pb.dart (Run dartfmt to format lib/src/proto/meta_graph.pb.dart.)
  • lib/src/proto/meta_graph.pbenum.dart (Run dartfmt to format lib/src/proto/meta_graph.pbenum.dart.)
  • lib/src/proto/meta_graph.pbjson.dart (Run dartfmt to format lib/src/proto/meta_graph.pbjson.dart.)
  • lib/src/proto/meta_graph.pbserver.dart (Run dartfmt to format lib/src/proto/meta_graph.pbserver.dart.)
  • lib/src/proto/node_def.pb.dart (Run dartfmt to format lib/src/proto/node_def.pb.dart.)
  • lib/src/proto/node_def.pbenum.dart (Run dartfmt to format lib/src/proto/node_def.pbenum.dart.)
  • lib/src/proto/node_def.pbjson.dart (Run dartfmt to format lib/src/proto/node_def.pbjson.dart.)
  • lib/src/proto/node_def.pbserver.dart (Run dartfmt to format lib/src/proto/node_def.pbserver.dart.)
  • lib/src/proto/op_def.pb.dart (Run dartfmt to format lib/src/proto/op_def.pb.dart.)
  • lib/src/proto/op_def.pbenum.dart (Run dartfmt to format lib/src/proto/op_def.pbenum.dart.)
  • lib/src/proto/op_def.pbjson.dart (Run dartfmt to format lib/src/proto/op_def.pbjson.dart.)
  • lib/src/proto/op_def.pbserver.dart (Run dartfmt to format lib/src/proto/op_def.pbserver.dart.)
  • lib/src/proto/resource_handle.pb.dart (Run dartfmt to format lib/src/proto/resource_handle.pb.dart.)
  • lib/src/proto/resource_handle.pbenum.dart (Run dartfmt to format lib/src/proto/resource_handle.pbenum.dart.)
  • lib/src/proto/resource_handle.pbjson.dart (Run dartfmt to format lib/src/proto/resource_handle.pbjson.dart.)
  • lib/src/proto/resource_handle.pbserver.dart (Run dartfmt to format lib/src/proto/resource_handle.pbserver.dart.)
  • lib/src/proto/rewriter_config.pb.dart (Run dartfmt to format lib/src/proto/rewriter_config.pb.dart.)
  • lib/src/proto/rewriter_config.pbenum.dart (Run dartfmt to format lib/src/proto/rewriter_config.pbenum.dart.)
  • lib/src/proto/rewriter_config.pbjson.dart (Run dartfmt to format lib/src/proto/rewriter_config.pbjson.dart.)
  • lib/src/proto/rewriter_config.pbserver.dart (Run dartfmt to format lib/src/proto/rewriter_config.pbserver.dart.)
  • lib/src/proto/saver.pb.dart (Run dartfmt to format lib/src/proto/saver.pb.dart.)
  • lib/src/proto/saver.pbenum.dart (Run dartfmt to format lib/src/proto/saver.pbenum.dart.)
  • lib/src/proto/saver.pbjson.dart (Run dartfmt to format lib/src/proto/saver.pbjson.dart.)
  • lib/src/proto/saver.pbserver.dart (Run dartfmt to format lib/src/proto/saver.pbserver.dart.)
  • lib/src/proto/step_stats.pb.dart (Run dartfmt to format lib/src/proto/step_stats.pb.dart.)
  • lib/src/proto/step_stats.pbenum.dart (Run dartfmt to format lib/src/proto/step_stats.pbenum.dart.)
  • lib/src/proto/step_stats.pbjson.dart (Run dartfmt to format lib/src/proto/step_stats.pbjson.dart.)
  • lib/src/proto/step_stats.pbserver.dart (Run dartfmt to format lib/src/proto/step_stats.pbserver.dart.)
  • lib/src/proto/tensor.pb.dart (Run dartfmt to format lib/src/proto/tensor.pb.dart.)
  • lib/src/proto/tensor.pbenum.dart (Run dartfmt to format lib/src/proto/tensor.pbenum.dart.)
  • lib/src/proto/tensor.pbjson.dart (Run dartfmt to format lib/src/proto/tensor.pbjson.dart.)
  • lib/src/proto/tensor.pbserver.dart (Run dartfmt to format lib/src/proto/tensor.pbserver.dart.)
  • lib/src/proto/tensor_description.pb.dart (Run dartfmt to format lib/src/proto/tensor_description.pb.dart.)
  • lib/src/proto/tensor_description.pbenum.dart (Run dartfmt to format lib/src/proto/tensor_description.pbenum.dart.)
  • lib/src/proto/tensor_description.pbjson.dart (Run dartfmt to format lib/src/proto/tensor_description.pbjson.dart.)
  • lib/src/proto/tensor_description.pbserver.dart (Run dartfmt to format lib/src/proto/tensor_description.pbserver.dart.)
  • lib/src/proto/tensor_shape.pb.dart (Run dartfmt to format lib/src/proto/tensor_shape.pb.dart.)
  • lib/src/proto/tensor_shape.pbenum.dart (Run dartfmt to format lib/src/proto/tensor_shape.pbenum.dart.)
  • lib/src/proto/tensor_shape.pbjson.dart (Run dartfmt to format lib/src/proto/tensor_shape.pbjson.dart.)
  • lib/src/proto/tensor_shape.pbserver.dart (Run dartfmt to format lib/src/proto/tensor_shape.pbserver.dart.)
  • lib/src/proto/types.pb.dart (Run dartfmt to format lib/src/proto/types.pb.dart.)
  • lib/src/proto/types.pbenum.dart (Run dartfmt to format lib/src/proto/types.pbenum.dart.)
  • lib/src/proto/types.pbjson.dart (Run dartfmt to format lib/src/proto/types.pbjson.dart.)
  • lib/src/proto/types.pbserver.dart (Run dartfmt to format lib/src/proto/types.pbserver.dart.)
  • lib/src/proto/versions.pb.dart (Run dartfmt to format lib/src/proto/versions.pb.dart.)
  • lib/src/proto/versions.pbenum.dart (Run dartfmt to format lib/src/proto/versions.pbenum.dart.)
  • lib/src/proto/versions.pbjson.dart (Run dartfmt to format lib/src/proto/versions.pbjson.dart.)
  • lib/src/proto/versions.pbserver.dart (Run dartfmt to format lib/src/proto/versions.pbserver.dart.)
  • lib/tensorflow.dart (Run dartfmt to format lib/tensorflow.dart.)

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.

Maintain CHANGELOG.md. (-20 points)

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

The description is too short. (-20 points)

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-v0.1 release. (-10 points)

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


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0