且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Keras输出形状具有额外的尺寸

更新时间:2023-12-01 23:46:34

在聊天中与@Dodge交谈时,他指出了以下文档:

Whilst speaking to @Dodge in chat he pointed me to the following docs:

https://www.tensorflow.org/api_docs/python /tf/keras/layers/Reshape

,其中指出其他无"来自批次长度.我需要将第一个网络的输出馈入第二个网络的输出中,而第二个网络的输出预计将不具有批处理维度,因此我在第一个网络的外部使用了重塑来删除了该网络,如下所示:

which states that the additional None comes from the batch length. I needed to feed the output of the first network into the output of a second which expected not to have the batch dimension so I removed this using a reshape outside of the first network like so:

#Adversierial network which is comprised of a generator network and a discriminator network.
self.model = Sequential([
   Gen_Input, # Generator Network
   Reshape((500, 500, 3), input_shape=(500, 500, 3)),
   discriminative_model.Input # Discriminator Network
        ])

这使我能够从图形内部重塑输出.

This allowed me to reshape the output from inside the graph.