LoginSignup
1
2

More than 5 years have passed since last update.

jsdoでdeeplearn.js

Posted at

概要

jsdoでdeeplearn.jsやってみた。

サンプルコード

var dl = deeplearn;
var graph = new dl.Graph();
var math = new dl.NDArrayMathCPU();

var inputA = [1];
var inputB = [1];
var inputTensorA = graph.placeholder('A', inputA);
var inputTensorB = graph.placeholder('B', inputB);
var sum = graph.add(inputTensorA, inputTensorB);
var feeds = [{
    tensor: inputTensorA,
    data: dl.Array1D.new([4.0])
}, {
    tensor: inputTensorB, 
    data: dl.Array1D.new([2.0])
}];
var sess = new dl.Session(graph, math);
math.scope(() => {
    var res = sess.eval(sum, feeds);
    alert(res.getValues());
});


成果物

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2