美文网首页
PYTHON:shape =(None,)+ state_dim

PYTHON:shape =(None,)+ state_dim

作者: zelda2333 | 来源:发表于2020-03-20 16:58 被阅读0次

转自:shape=(None,)+stat_dim & shape=(None, state_dim)区别

  • shape=(None,)+stat_dim
    这将两个元组连接成一个元组。所以,你得到一个4元素的元组,就像3元素元组一样stat_dim,但是None在开始时有额外的值。
>>> stat_dim = (1, 2, 3)
>>> (None,) + stat_dim
(None, 1, 2, 3)
>>> (1, 2) + (3, 4)
(1, 2, 3, 4)
>>> shape = (None,) + stat_dim
>>> shape[2]
2
  • shape=(None, state_dim)
    这将创建一个双元素元组,其第一个元素是None,而第二个元素是stat_dim元组。
>>> (None, stat_dim)
(None, (1, 2, 3))
>>> ((1, 2), (3, 4))
((1, 2), (3, 4)

所以现在没有shape[2]; 只有shape[0]和shape[1],然后shape[1]有自己的元素:

>>> shape = (None, stat_dim)
>>> shape[2]
IndexError: tuple index out of range
>>> shape[1][2]
3

相关文章

网友评论

      本文标题:PYTHON:shape =(None,)+ state_dim

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