@tensorflow/tfjs
Advanced tools
Comparing version 0.6.1 to 0.7.0
@@ -1,2 +0,2 @@ | ||
declare const version = "0.6.1"; | ||
declare const version = "0.7.0"; | ||
export { version }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var version = '0.6.1'; | ||
var version = '0.7.0'; | ||
exports.version = version; |
{ | ||
"name": "@tensorflow/tfjs", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "An open-source machine learning framework.", | ||
@@ -16,5 +16,15 @@ "private": false, | ||
"devDependencies": { | ||
"@types/jasmine": "~2.8.6", | ||
"@types/node": "~9.6.1", | ||
"browserify": "~16.1.1", | ||
"jasmine-core": "~3.1.0", | ||
"karma": "~2.0.0", | ||
"karma-browserstack-launcher": "~1.3.0", | ||
"karma-chrome-launcher": "~2.2.0", | ||
"karma-firefox-launcher": "~1.1.0", | ||
"karma-jasmine": "~1.1.1", | ||
"karma-typescript": "~3.0.12", | ||
"rimraf": "~2.6.2", | ||
"tsify": "~3.0.4", | ||
"tslint": "~5.9.1", | ||
"typescript": "2.7.2", | ||
@@ -25,8 +35,11 @@ "uglify-js": "~3.0.28" | ||
"build": "tsc", | ||
"build-npm": "./scripts/build-npm.sh" | ||
"build-npm": "./scripts/build-npm.sh", | ||
"lint": "tslint -p . -t verbose", | ||
"test": "karma start", | ||
"test-travis": "karma start --browsers='bs_firefox_mac,bs_chrome_mac' --singleRun" | ||
}, | ||
"dependencies": { | ||
"@tensorflow/tfjs-core": "0.6.0", | ||
"@tensorflow/tfjs-layers": "0.1.2" | ||
"@tensorflow/tfjs-layers": "0.2.0" | ||
} | ||
} |
153
README.md
# TensorFlow.js | ||
TensorFlow.js is an open-source hardware-accelerated JavaScript library for | ||
building, training and serving machine learning models. When running in the | ||
browser, it utilizes WebGL acceleration. TensorFlow.js is also convenient and | ||
intuitive, modeled after | ||
[Keras](https://keras.io/) and | ||
[tf.layers](https://www.tensorflow.org/api_docs/python/tf/layers) and can | ||
load models saved from those libraries. | ||
training and deploying machine learning models. | ||
This repository conveniently contains the logic and scripts to form | ||
a version-matched **union** package, | ||
[@tensorflowjs/tfjs](https://www.npmjs.com/package/@tensorflow/tfjs), from | ||
**Develop ML in the Browser** <br/> | ||
Use flexible and intuitive APIs to build models from scratch using the low-level | ||
JavaScript linear algebra library or the high-level layers API. | ||
- [TensorFlow.js Core](https://github.com/tensorflow/tfjs-core), | ||
a flexible low-level API, formerly known as *deeplearn.js*. | ||
- [TensorFlow.js Layers](https://github.com/tensorflow/tfjs-layers), | ||
a high-level API modeled after [Keras](https://keras.io/). | ||
**Run Existing models** <br/> | ||
Use TensorFlow.js model converters to run pre-existing TensorFlow models right | ||
in the browser. | ||
**Retrain Existing models** <br/> | ||
Retrain pre-existing ML models using sensor data connected to the browser, or | ||
other client-side data. | ||
## Importing | ||
You can import TensorFlow.js Union directly via yarn or npm. | ||
You can import TensorFlow.js directly via yarn or npm: | ||
`yarn add @tensorflow/tfjs` or `npm install @tensorflow/tfjs`. | ||
See snippets below for examples. | ||
Alternatively you can use a script tag. Here we load it from a CDN. | ||
In this case it will be available as a global variable named `tf`. | ||
Alternatively you can use a script tag. The library will be available as | ||
a global variable named `tf`: | ||
You can replace also specify which version to load replacing `@latest` | ||
with a specific | ||
version string (e.g. `0.6.0`). | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/tensorflow/tfjs@latest"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"></script> | ||
<!-- or --> | ||
<script src="https://unpkg.com/tensorflow/tfjs@latest"></script> | ||
<script src="https://unpkg.com/@tensorflow/tfjs@latest"></script> | ||
``` | ||
You can also specify which version to load replacing `@latest` | ||
with a specific version string (e.g. `0.6.0`). | ||
## Usage Examples | ||
## About this repo | ||
Many examples illustrating how to use TensorFlow.js in ES5, ES6 and | ||
TypeScript are available from the | ||
[Examples repository](https://github.com/tensorflow/tfjs-examples) | ||
and the | ||
[TensorFlow.js Tutorials](https://js.tensorflow.org/tutorials/) | ||
This repository contains the logic and scripts that combine | ||
two packages: | ||
- [TensorFlow.js Core](https://github.com/tensorflow/tfjs-core), | ||
a flexible low-level API, formerly known as *deeplearn.js*. | ||
- [TensorFlow.js Layers](https://github.com/tensorflow/tfjs-layers), | ||
a high-level API which implements functionality similar to | ||
[Keras](https://keras.io/). | ||
If you care about bundle size, you can import those packages individually. | ||
### Direct tensor manipulation | ||
## Examples | ||
Let's add a scalar value to a 1D Tensor. TensorFlow.js supports _broadcasting_ | ||
Check out our | ||
[examples repository](https://github.com/tensorflow/tfjs-examples) | ||
and our [tutorials](https://js.tensorflow.org/tutorials/). | ||
## Migrating from deeplearn.js | ||
See [these release notes](https://github.com/tensorflow/tfjs-core/releases/tag/v0.6.0) | ||
for how to migrate from deeplearn.js to TensorFlow.js. | ||
## Getting started | ||
Let's add a scalar value to a vector. TensorFlow.js supports _broadcasting_ | ||
the value of scalar over all the elements in the tensor. | ||
@@ -73,7 +80,4 @@ | ||
### Building, training, and executing a model using Layers | ||
Now, let's build a toy model to perform linear regression. | ||
The following example shows how to build a toy model with only one `dense` layer | ||
to perform linear regression. | ||
```js | ||
@@ -89,3 +93,3 @@ import * as tf from '@tensorflow/tfjs'; | ||
// Specify the loss type and optimizer for training. | ||
model.compile({loss: 'meanSquaredError', optimizer: 'SGD'}); | ||
model.compile({loss: 'meanSquaredError', optimizer: 'sgd'}); | ||
@@ -99,3 +103,3 @@ // Generate some synthetic data for training. | ||
// Ater the training, perform inference. | ||
// After the training, perform inference. | ||
const output = model.predict(tf.tensor2d([[5]], [1, 1])); | ||
@@ -105,70 +109,19 @@ output.print(); | ||
For a deeper dive into building a layers classifier, see the | ||
For a deeper dive into building models, see the | ||
[MNIST tutorial](https://js.tensorflow.org/tutorials/mnist.html) | ||
## Importing pre-trained models | ||
### Loading a pretrained Keras model using Layers | ||
We support porting pre-trained models from: | ||
- [TensorFlow SavedModel](https://github.com/tensorflow/tfjs-converter) | ||
- [Keras](https://js.tensorflow.org/tutorials/import-keras.html) | ||
You can also load a model previously trained and saved from elsewhere (e.g., | ||
from Python Keras) and use it for inference or transfer learning in the browser. | ||
More details in the | ||
[import-keras tutorial](https://js.tensorflow.org/tutorials/import-keras.html) | ||
## Find out more | ||
For example, in Python, save your Keras model using | ||
[tensorflowjs](https://pypi.org/project/tensorflowjs/), | ||
which can be installed using `pip install tensorflowjs`. | ||
[TensorFlow.js](https://js.tensorflow.org) is a part of the | ||
[TensorFlow](https://www.tensorflow.org) ecosystem. For more info: | ||
- [js.tensorflow.org](https://js.tensorflow.org) | ||
- [Tutorials](https://js.tensorflow.org/tutorials) | ||
- [API reference](https://js.tensorflow.org/api/latest/) | ||
- [Help mailing list](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfjs) | ||
```python | ||
import tensorflowjs as tfjs | ||
# ... Create and train your Keras model. | ||
# Save your Keras model in TensorFlow.js format. | ||
tfjs.converters.save_keras_model(model, '/path/to/tfjs_artifacts/') | ||
# Then use your favorite web server to serve the directory at a URL, say | ||
# http://foo.bar/tfjs_artifacts/model.json | ||
``` | ||
To load the model with TensorFlow.js Layers: | ||
```js | ||
import * as tf from '@tensorflow/tfjs'; | ||
const model = await tf.loadModel('http://foo.bar/tfjs_artifacts/model.json'); | ||
// Now the model is ready for inference, evaluation or re-training. | ||
``` | ||
## How to find more! | ||
Again, see the | ||
[Examples repository](https://github.com/tensorflow/tfjs-examples) and the | ||
[TensorFlow.js Tutorials](https://js.tensorflow.org/tutorials/) | ||
for many more examples of how to build models and manipulate tensors. | ||
## Supported Environments | ||
**TensorFlow.js** targets environments with WebGL 1.0 or WebGL 2.0. For devices | ||
without the `OES_texture_float` extension, we fall back to fixed precision | ||
floats backed by a `gl.UNSIGNED_BYTE` texture. For platforms without WebGL, | ||
we provide CPU fallbacks. | ||
## Additional Resources | ||
TensorFlow.js is a part of the | ||
[TensorFlow](https://www.tensorflow.org) ecosystem. | ||
You can import pre-trained TensorFlow | ||
[SavedModels](https://www.tensorflow.org/programmers_guide/saved_model) and | ||
[Keras models](https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model), | ||
for execution and retraining. | ||
For more information on the API, follow the links to their Core and Layers | ||
repositories below, or visit [js.tensorflow.org](https://js.tensorflow.org). | ||
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1614734
10
24393
15
124
+ Added@tensorflow/tfjs-layers@0.2.0(transitive)
- Removed@tensorflow/tfjs-layers@0.1.2(transitive)