a = tf.compat.v1.constant(5.0)
b = tf.compat.v1.constant(6.0)
sum1 = a + b
g = tf.compat.v1.Graph()
with g.as_default():
# Define operations and tensors in `g`.
hello = tf.compat.v1.constant('hello')
assert hello.graph is g
sess = tf.compat.v1.Session(graph=g)
print(sess.run(sum1))
tensorflow-gpu2.0 我不知道为什么。我是tensorflow的初学者
答案 0 :(得分:3)
导入 tensorflow 后需要禁用 Eager Execution,如下所示:
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
它对我有用。
答案 1 :(得分:0)
我不知道你想做什么!但我做了一些猜测,这就是我得出的结果。
import tensorflow as tf
g = tf.compat.v1.Graph()
with g.as_default():
a = tf.compat.v1.constant(5.0)
b = tf.compat.v1.constant(6.0)
sum1 = tf.add(a, b) # instead of sum1 = a + b
hello = tf.compat.v1.constant('hello')
assert hello.graph is g
sess = tf.compat.v1.Session(graph=g)
print(sess.run(sum1))
我相信它适用于 Tensorflow 2.x,如果您仍然遇到急切的异常,那么您应该添加:
tf.compat.v1.disable_eager_execution()
之前
assert hello.graph is g
答案 2 :(得分:-1)
我尝试了Tensorflow版本1.14.0
执行以下操作
select member,
min(case when prev_tot = 'PREVENTATIVE' and tot = 'TREATMENT'
then date
end) as first_prev_to_treat_date
from (select t.*,
lag(tot) over (partition by member order by date) as prev_tot
from t
) t
group by member;
尝试以下代码
pip install tensorflow==1.14..0