title: Using TensorFlow in R for solving equation
body: <p>I am working on learning to solve equations in R and I am interested in doing it through TensorFlow (I already know how to do it using GA and Simulated Annealing). I am beginning with a simple equation: Y = X + Z, where X and Y are known and Z is to be estimated. This can be easily done in python, see this <a href="https://medium.com/@liccowee/tensorflow-to-solve-simple-math-equation-27f42a44f0f1" rel="nofollow noreferrer">blog</a>.</p>
  
  <p>When I run the following code, I get an error when executing the evaln line:</p>
  
  <pre><code>x = tf$constant(c(1.,2.))
  y = tf$constant(c(12,4))
  Z = tf$Variable(tf$zeros(2,1))
  yy = tf$add(x, Z)
  deviation = tf$square(y - yy)
  
  opt = tf$optimizers$Adam(0.01)
  
  evaln = compile(object = yy, optimizer = opt, loss = deviation)
  </code></pre>
  
  <blockquote>
    <p>Error in UseMethod("compile") : 
      no applicable method for 'compile' applied to an object of class "c('tensorflow.tensor', 'tensorflow.python.framework.ops.EagerTensor', 'tensorflow.python.framework.ops._EagerTensorBase', 'tensorflow.python.framework.ops.Tensor', 'tensorflow.python.framework.tensor_like._TensorLike', 'python.builtin.object')</p>
  </blockquote>
  
  <p>I can guess that the error means I need to pass tensorflow model class object to "object" parameter in "compile" function but I have not been able to figure how to solve this. Anyone has an idea how this can be done in R using TensorFlow.</p>