eaplatanios / tensorflow_scala

TensorFlow API for the Scala Programming Language
http://platanios.org/tensorflow_scala/
Apache License 2.0
936 stars 95 forks source link

Questions #81

Closed rikvdkleij closed 6 years ago

rikvdkleij commented 6 years ago

How do I run the initializer of a variable (just like in Python API)? After assigning a tensor to a variable, do I have to evaluate the result (just like in Python API)? Is

var.assign(t)

sufficient? In Python API:

session.run(tf.assign(var,t))

Okay, found already the answer for this question. It is:

session.run(targets = var.assign(t))
rikvdkleij commented 6 years ago

Other question: When do I have to call evaluate? Is that only to for example to print the current value of Output or variabele?

rikvdkleij commented 6 years ago

Yet another question, but important question. How do I write only the graph to disk like in Python in this way?

tf.train.write_graph(sess.graph, 'model', 'model.pbtxt')

I only see a way to write graph as part of event file, in this way:

tf.summary.FileWriter(Paths.get("model"), session.graph)
rikvdkleij commented 6 years ago

Solved it by:

  val graphDef = session.graph.toProto
  new PrintWriter("model.pbtxt") { write(graphDef.toString); close }

Do not see other solution.