美文网首页
placeholder vs. tf.variable()区别

placeholder vs. tf.variable()区别

作者: 啊啊啊啊啊1231 | 来源:发表于2020-03-24 13:35 被阅读0次

#!/usr/bin/env/python

# coding=utf-8

import tensorflow as tf

import numpy as np

input_ids = tf.placeholder(dtype=tf.int32, shape=[None])

embedding = tf.Variable(np.identity(5, dtype=np.int32))

input_embedding = tf.nn.embedding_lookup(embedding, input_ids)

sess = tf.InteractiveSession()

sess.run(tf.global_variables_initializer())

print(embedding.eval())

print(sess.run(input_embedding, feed_dict={input_ids:[1, 2, 3, 0, 3, 2, 1]}))

tfplaceholder表示未知变量

tf.variable代表已知变量

相关文章

网友评论

      本文标题:placeholder vs. tf.variable()区别

      本文链接:https://www.haomeiwen.com/subject/axvuyhtx.html