search

Home  >  Q&A  >  body text

python - _, 表示什么意思呢

在tensorflow一个学习代码中遇到了这样一行代码:
_, loss_value = sess.run()

想请问一下这个_,表示什么意思呢

PHPzPHPz2787 days ago1223

reply all(6)I'll reply

  • PHPz

    PHPz2017-04-18 10:28:25

    Variables that can be ignored

    _ Just a placeholder

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:28:25

    If you are in REPL, _ can represent the return value of the previous step
    For example

    >>> (lambda : 2)()
    2
    >>> _
    2
    

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:28:25

    represents the variable name

    reply
    0
  • PHPz

    PHPz2017-04-18 10:28:25

    sess.run() returns two parameters, the first parameter is saved in a variable named _. If _ is printed separately, it represents the value of the latest expression

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 10:28:25

    Indicates variables that will be discarded, crying face

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 10:28:25

    means that func is supposed to return two variables, but you only want to receive the latter variable, so use _ to occupy a position to indicate that it has been received

    reply
    0
  • Cancelreply