jsdo
deeplearn.js

概要

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());
});


成果物

http://jsdo.it/ohisama1/coBe