tensorflow 0.0.0

  • README.md
  • Example
  • Installing
  • Versions
  • new45

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


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

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
99 / 100
Reflects how tidy and up-to-date the package is. [more]
78 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: other

Primary library: package:tensorflow/tensorflow.dart with components: nativewrappers.


  • Maintain CHANGELOG.md.

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

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 152 hints.

    Strong-mode analysis of lib/src/dart/graph.dart gave the following hint:

    line: 170 col: 17
    Always override hashCode if overriding ==.

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

    Similar analysis of the following files failed:

    • lib/src/dart/saved_model_bundle.dart (hint)
    • lib/src/dart/shape.dart (hint)
    • lib/src/proto/allocation_description.pb.dart (hint)
    • lib/src/proto/allocation_description.pbenum.dart (hint)
    • lib/src/proto/allocation_description.pbjson.dart (hint)
    • lib/src/proto/allocation_description.pbserver.dart (hint)
    • lib/src/proto/any.pb.dart (hint)
    • lib/src/proto/any.pbenum.dart (hint)
    • lib/src/proto/any.pbjson.dart (hint)
    • lib/src/proto/any.pbserver.dart (hint)
    • lib/src/proto/attr_value.pb.dart (hint)
    • lib/src/proto/attr_value.pbenum.dart (hint)
    • lib/src/proto/attr_value.pbjson.dart (hint)
    • lib/src/proto/attr_value.pbserver.dart (hint)
    • lib/src/proto/cluster.pb.dart (hint)
    • lib/src/proto/cluster.pbenum.dart (hint)
    • lib/src/proto/cluster.pbjson.dart (hint)
    • lib/src/proto/cluster.pbserver.dart (hint)
    • lib/src/proto/config.pb.dart (hint)
    • lib/src/proto/config.pbenum.dart (hint)
    • lib/src/proto/config.pbjson.dart (hint)
    • lib/src/proto/config.pbserver.dart (hint)
    • lib/src/proto/cost_graph.pb.dart (hint)
    • lib/src/proto/cost_graph.pbenum.dart (hint)
    • lib/src/proto/cost_graph.pbjson.dart (hint)
    • lib/src/proto/cost_graph.pbserver.dart (hint)
    • lib/src/proto/debug.pb.dart (hint)
    • lib/src/proto/debug.pbenum.dart (hint)
    • lib/src/proto/debug.pbjson.dart (hint)
    • lib/src/proto/debug.pbserver.dart (hint)
    • lib/src/proto/function.pb.dart (hint)
    • lib/src/proto/function.pbenum.dart (hint)
    • lib/src/proto/function.pbjson.dart (hint)
    • lib/src/proto/function.pbserver.dart (hint)
    • lib/src/proto/graph.pb.dart (hint)
    • lib/src/proto/graph.pbenum.dart (hint)
    • lib/src/proto/graph.pbjson.dart (hint)
    • lib/src/proto/graph.pbserver.dart (hint)
    • lib/src/proto/meta_graph.pb.dart (hint)
    • lib/src/proto/meta_graph.pbenum.dart (hint)
    • lib/src/proto/meta_graph.pbjson.dart (hint)
    • lib/src/proto/meta_graph.pbserver.dart (hint)
    • lib/src/proto/node_def.pb.dart (hint)
    • lib/src/proto/node_def.pbenum.dart (hint)
    • lib/src/proto/node_def.pbjson.dart (hint)
    • lib/src/proto/node_def.pbserver.dart (hint)
    • lib/src/proto/op_def.pb.dart (hint)
    • lib/src/proto/op_def.pbenum.dart (hint)
    • lib/src/proto/op_def.pbjson.dart (hint)
    • lib/src/proto/op_def.pbserver.dart (hint)
    • lib/src/proto/resource_handle.pb.dart (hint)
    • lib/src/proto/resource_handle.pbenum.dart (hint)
    • lib/src/proto/resource_handle.pbjson.dart (hint)
    • lib/src/proto/resource_handle.pbserver.dart (hint)
    • lib/src/proto/rewriter_config.pb.dart (hint)
    • lib/src/proto/rewriter_config.pbenum.dart (hint)
    • lib/src/proto/rewriter_config.pbjson.dart (hint)
    • lib/src/proto/rewriter_config.pbserver.dart (hint)
    • lib/src/proto/saver.pb.dart (hint)
    • lib/src/proto/saver.pbenum.dart (hint)
    • lib/src/proto/saver.pbjson.dart (hint)
    • lib/src/proto/saver.pbserver.dart (hint)
    • lib/src/proto/step_stats.pb.dart (hint)
    • lib/src/proto/step_stats.pbenum.dart (hint)
    • lib/src/proto/step_stats.pbjson.dart (hint)
    • lib/src/proto/step_stats.pbserver.dart (hint)
    • lib/src/proto/tensor.pb.dart (hint)
    • lib/src/proto/tensor.pbenum.dart (hint)
    • lib/src/proto/tensor.pbjson.dart (hint)
    • lib/src/proto/tensor.pbserver.dart (hint)
    • lib/src/proto/tensor_description.pb.dart (hint)
    • lib/src/proto/tensor_description.pbenum.dart (hint)
    • lib/src/proto/tensor_description.pbjson.dart (hint)
    • lib/src/proto/tensor_description.pbserver.dart (hint)
    • lib/src/proto/tensor_shape.pb.dart (hint)
    • lib/src/proto/tensor_shape.pbenum.dart (hint)
    • lib/src/proto/tensor_shape.pbjson.dart (hint)
    • lib/src/proto/tensor_shape.pbserver.dart (hint)
    • lib/src/proto/types.pb.dart (hint)
    • lib/src/proto/types.pbenum.dart (hint)
    • lib/src/proto/types.pbjson.dart (hint)
    • lib/src/proto/types.pbserver.dart (hint)
    • lib/src/proto/versions.pb.dart (hint)
    • lib/src/proto/versions.pbenum.dart (hint)
    • lib/src/proto/versions.pbjson.dart (hint)
    • lib/src/proto/versions.pbserver.dart (hint)
    • lib/tensorflow.dart (hint)
  • 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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
binary ^0.1.3 0.1.3
collection ^1.0.0 1.14.10
fixnum ^0.10.7 0.10.7
meta ^1.0.0 1.1.5
path ^1.0.0 1.6.0
protobuf ^0.7.2 0.7.2 0.9.0
symbol_table ^1.0.0 1.0.4
tuple ^1.0.0 1.0.1
Transitive dependencies
quiver_hashcode 1.0.0
Dev dependencies
args ^1.0.0
cli_util ^0.1.3
code_builder ^3.0.0
dart_style ^1.0.0
recase ^1.0.0
system_info ^0.0.16
test ^0.12.0
vector_math ^2.0.0