Giter Site home page Giter Site logo

tensorflow.dart's Introduction




Pub Build status Gitter License

Tensorflow API for the Dart programming language.

The revised goal of this project to provide an API for running pre-built Tensorflow models/graphs, typically built in another language, like Python.

Installation

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.

The Pub package does include pre-built libraries, but your mileage may vary. It may make sense in your case to run the CMake build from within your ~/.pub-cache locally.

Prerequisites

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

Building as a Dependency

If you are using package:tensorflow as a dependency in a Dart project, then you may be able to get by with the pre-built dynamic libraries in the lib/ folder. If not, you will have to manually enter the ~/.pub-cache and run the build.

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 CMakeLists.txt 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 = SavedModelBundle('example/saved_models');
  model.restore('variables.index');

  // Or, you can import from a `GraphDef` protocol buffer:
  var graph = Graph.fromGraphDef(graphDef);
  graph['output'].run(feed: {'input': Tensor.from('Hello, world!')});
}

Low Level API

package:tensorflow/tensorflow.dart theoretically 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. These bindings are, for the most part, auto-generated, and there is not much incentive to properly unit test them, considering that the most common use of this package will be to execute existing Tensorflow models from other languages.

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

void main() {
    var shape = tf.Shape(6, 6);

    var x = tf.getVariable(
      'x',
      shape: shape,
      initializer: tf.randomUniform(
        tf.constant(shape),
        dtype: tf.DataType.DT_FLOAT,
      ),
    );

    x = tf.matMul(x, x);

    print(x.run());
}

tensorflow.dart's People

Contributors

thosakwe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tensorflow.dart's Issues

Doesn't work

flutter pub get
Running "flutter pub get" in somemlproject...
The current Dart SDK version is 2.8.4.

Because every version of tensorflow depends on protobuf >=0.2.0 <=0.9.0 which requires SDK version >=0.7.5 <2.0.0-โˆž, tensorflow is forbidden.

So, because somemlproject depends on tensorflow ^0.0.0, version solving failed.
pub get failed (1; So, because somemlproject depends on tensorflow ^0.0.0, version solving failed.)
exit code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.