1.在学习cws时,对Embeedings的赋值产生了疑问,但是我几经尝试和搜索之后并未找到实际办法
import tensorflow as tfembeddings = tf.Variable('embedding', [2,2])init=tf.global_variables_initializer()with tf.Session() as sess: sess.run(init) value=sess.run(embeddings) value[bytes(0)]=bytes([1,1]) sess.run(embeddings.assign(value)) print(sess.run(embeddings))## File "D:\Code\test.pyw", line 8, in## value[bytes(0)]=bytes([1,1])##TypeError: 'bytes' object does not support item assignment##这里不知该如何赋值。
2.RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument
出现这类问题时,是因为没有将所有的data和model都转移到gpu上,而只转移了一部分,需要继续检查以转移。