best_session_run

2023-02-02  本文已影响0人  Lonelyroots

best_session_run

import tensorflow as tf

x = tf.Variable(3, name='x')
y = tf.Variable(4, name='y')
f = x*x*y + y + 2
print(f)

with tf.Session() as sess:
    x.initializer.run()     # 等价于tf.get_default_session().run(x.initializer)
    y.initializer.run()     # 等价于tf.get_default_session().run(y.initializer)
    result = f.eval()       # 等价于 tf.get_default_session().run(f)    

print(result)

文章到这里就结束了!希望大家能多多支持Python(系列)!六个月带大家学会Python,私聊我,可以问关于本文章的问题!以后每天都会发布新的文章,喜欢的点点关注!一个陪伴你学习Python的新青年!不管多忙都会更新下去,一起加油!

Editor:Lonelyroots

上一篇下一篇

猜你喜欢

热点阅读