Aravind Pilla
Aravind Pilla

Reputation: 416

Getting error with exp, sin, cos functions in tensorflow

import numpy as np
import tensorflow as tf

b = tf.constant(2)

**sess.run(tf.exp(b))**

Error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/aravindp/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 340, in run
    run_metadata_ptr)
  File "/home/aravindp/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 564, in _run
    feed_dict_string, options, run_metadata)
  File "/home/aravindp/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 637, in _do_run
    target_list, options, run_metadata)
  File "/home/aravindp/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 659, in _do_call
    e.code)
**tensorflow.python.framework.errors.InvalidArgumentError: No OpKernel was registered to support Op 'Exp' with these attrs**
     [[Node: Exp = Exp[T=DT_INT32](Const_1)]]
Caused by op u'Exp', defined at:
  File "<stdin>", line 1, in <module>
  File "/home/aravindp/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 505, in exp
    return _op_def_lib.apply_op("Exp", x=x, name=name)
  File "/home/aravindp/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 655, in apply_op
    op_def=op_def)
  File "/home/aravindp/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2154, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/home/aravindp/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1154, in __init__
    self._traceback = _extract_stack()

>>> 

Upvotes: 0

Views: 541

Answers (1)

Sung Kim
Sung Kim

Reputation: 8536

Try with this:

import tensorflow as tf

b = tf.constant(2.)
sess = tf.Session()
print (sess.run(tf.exp(b)))

Upvotes: 1

Related Questions