Giter Club home page Giter Club logo

tfjs-core's Introduction

TensorFlow.js Core API

A part of the TensorFlow.js ecosystem, this repo hosts @tensorflow/tfjs-core, the TensorFlow.js Core API, which provides low-level, hardware-accelerated linear algebra operations and an eager API for automatic differentiation.

Check out js.tensorflow.org for more information about the library, tutorials and API docs.

To keep track of issues we use the tensorflow/tfjs Github repo.

Importing

You can install TensorFlow.js via yarn or npm. We recommend using the @tensorflow/tfjs npm package, which gives you both this Core API and the higher-level Layers API:

import * as tf from '@tensorflow/tfjs';
// You have the Core API: tf.matMul(), tf.softmax(), ...
// You also have Layers API: tf.model(), tf.layers.dense(), ...

On the other hand, if you care about the bundle size and you do not use the Layers API, you can import only the Core API:

import * as tfc from '@tensorflow/tfjs-core';
// You have the Core API: tfc.matMul(), tfc.softmax(), ...
// No Layers API.

For info about development, check out DEVELOPMENT.md.

For more information

Thanks BrowserStack for providing testing support.

tfjs-core's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

haoyunfeix

tfjs-core's Issues

MatMul case fails with MatMulPackedProgramCS

Add code below into mobilenet/index.js to test.

let x = tf.tensor2d([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],[4,6]);
let k = tf.tensor2d([1,0,0,1,1,0,1,0,0,1,0,1],[6,2]);
x.matMul(k).print(1);

An incorrect result will occur.

Tensor
  dtype: float32
  rank: 2
  shape: [4,2]
  values:
    [[32, 13],
     [50, 31],
     [20, 49],
     [38, 67]]

render pipeline + cs pipeline makes result incorrect

TEST ENV:
Windows10, Chrome Canary(Version 77.0.3819.0), D3D11 backend.

CASE:

const inputShape = [1,3,3,1]; /*Ni,Hi,Wi,Ci*/
const filterShape = [2,2,1,1]; /*Hk,Wk,Ci,Co*/
const stride = 1;
const pad = 'valid';

const x = tf.tensor4d([1,2,3,4,5,6,7,8,9], inputShape);
const w = tf.tensor4d([1,1,1,1], filterShape);

const result = tf.conv2d(x, w, stride, pad);
result.print(1);

this case will use 3 ops:

if changing im2col or packTensor to render pipeline, result will be wrong.

wrong result:

Tensor
  dtype: float32
  rank: 4
  shape: [1,2,2,1]
  values:
    [[[[0],
       [0]],

      [[0],
       [0]]]]

tfjs-examples/mnist could not run correctly on compute-context

tfjs-examples/mnist could not run correctly on compute-context. It is related with that some operators could not work normally on compute-context.
These operators are as bleow,
batchMatMul, reduce, realDivide, add, subtract, exp, relu, conv2d, unpackTensor

depthwiseConv2d shader generate error

Errors:
Uncaught (in promise) TypeError: Cannot read property '0' of null
at getSampler2DCS (shader_compiler.ts:1577)
at getSamplerFromInInfoCS (shader_compiler.ts:172)
at getSampler4DCS (shader_compiler.ts:2006)
at getSamplerFromInInfoCS (shader_compiler.ts:176)
at getInputSamplingSnippetCS (shader_compiler.ts:227)
at shader_compiler.ts:107
at Array.map ()
at makeCSShader (shader_compiler.ts:106)
at compileCSProgram (gpgpu_math.ts:135)
at backend_webgl.ts:2435

Sample code:
async function depthwiseConv2dTestSingleDepth_() {
const fSize = 2;
const pad = 'valid';
const stride = 1;
const chMul = 1;
const inDepth = 1;
ENV.set('WEBGL_PACK', false);
console.log(ENV.get('WEBGL_PACK'));
const x = tf.tensor4d(
[
0, 1, 2, 5, 0, 5,
0, 1, 5
],
[1, 3, 3, inDepth]);
const w = tf.tensor4d(
[1.0, 2.0, 2.0, 2.0],
[fSize, fSize, inDepth, chMul],
);

const result = tf.depthwiseConv2d(x, w, stride, pad);
result.print();
}

depthwiseConv2dTestSingleDepth_();

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.