zoukankan      html  css  js  c++  java
  • 错误尝试【待学习】

    1.在学习cws时,对Embeedings的赋值产生了疑问,但是我几经尝试和搜索之后并未找到实际办法

    import tensorflow as tf
    
    embeddings = 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	est.pyw", line 8, in <module>
    ##    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上,而只转移了一部分,需要继续检查以转移。

  • 相关阅读:
    JDBC_查询
    微信web小程序开发1
    小型人口普查系统2
    小型人口普查系统1
    JSP内置对象作用域
    Session和Cookie的区别
    Cookie
    Session
    c++中嵌入python
    目标文件obj的各段 2
  • 原文地址:https://www.cnblogs.com/BlueBlueSea/p/11205111.html
Copyright © 2011-2022 走看看