Skip to content

Instantly share code, notes, and snippets.

@kjunichi
Created October 21, 2016 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjunichi/7cb6993575fd67759b46f62f36fcc2ff to your computer and use it in GitHub Desktop.
Save kjunichi/7cb6993575fd67759b46f62f36fcc2ff to your computer and use it in GitHub Desktop.
mrubyでtensorflowをうごかす
j.eval('ENV["PYTHON"]=""')
j.eval('Pkg.update()')
j.eval('Pkg.add("PyCall")')

 j.eval('pyimport_conda("google.protobuf","protobuf")')                                                            
 => nil
> j.eval('pyimport_conda("tensorflow","tensorflow","conda-forge")')
 => nil
> j.eval('@pyimport tensorflow as tf')')
* ;
* ^C
> j.eval('@pyimport tensorflow as tf')
 => nil
> j.eval('sess = tf.Session()')                                                                                     
 => nil
> j.eval('a = tf.constant(10)')
 => nil
> j.eval('b = tf.constant(32)')
 => nil
> j.eval('sess[:run](pyeval("a + b", a=a, b=b))')
 => nil
> j.eval('string(sess[:run](pyeval("a + b", a=a, b=b)))')                                                           
 => "42"
> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment