我对以下代码行感到困惑:
input_img = Input(shape=(53,))
我有52张图片,但是元组在逗号后怎么都没有呢?这是什么意思?
输入函数除了参数形状的元组外
使用逗号可以使您用一个项目定义一个元组。如果仅使用(53)或53,它将被解释为整数:
type( 53 )
<class 'int'>
type( (53) )
<class 'int'>
type( (53,) )
<class 'tuple'>
这是因为在计算中使用了简单的方括号,因此无法将其解析为元组:
(53) + 2 # would raise an error if (53) was a tuple
(53 + 1)*2 # would also raise an error if (53+1) was a tuple
因此,为了用一个项目定义一个元组,您必须添加逗号:(53,)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句