nikhilk / node-tensorflow

Node.js + TensorFlow
Apache License 2.0
587 stars 59 forks source link

Enable JSON-based graph construction #22

Closed nikhilk closed 6 years ago

nikhilk commented 6 years ago

We should be able to construct a graph in node.js using protocol-buffers directly. For example:

var node1 = {
  name: 'Const',
  op: 'Const',
  attr: {
    dtype: {
      type: 3
    },
    value: {
      tensor: {
        dtype: 3,
        tensorShape: {},
        int_val: [1]
      }
    }
  }
}

var graph = {
  node: [
    node1
  ]
}

let graph = tf.Graph.fromGraphDefObject(graph)

Which uses the encode method of the compiled protobuf message.

While the encode and subsequent construction of a Graph and Session works fine, session.run results in a segmentation fault, suggesting an invalid attribute or some other detail of the graph.

nikhilk commented 6 years ago

Addressed in ecd28d71fa944ec7ecda920ee07650d9c371288c

nikhilk commented 6 years ago

Functionality included in 0.7.0.