【发布时间】:2018-05-13 08:26:53
【问题描述】:
我又来找你了,我可以开始工作,但真的很慢。希望大家帮我优化一下。
我正在尝试在 TensorFlow 中实现卷积自动编码器,编码器和解码器之间的潜在空间很大。通常,我们会使用全连接层将编码器连接到解码器,但由于该潜在空间具有高维度,这样做会创建太多特征,使其在计算上不可行。
我在this paper 中找到了一个很好的解决方案。他们称之为“通道全连接层”。它基本上是每个通道的全连接层。
我正在着手实施,我已经开始工作了,但是图表的生成需要很长时间。到目前为止,这是我的代码:
def _network(self, dataset, isTraining):
encoded = self._encoder(dataset, isTraining)
with tf.variable_scope("fully_connected_channel_wise"):
shape = encoded.get_shape().as_list()
print(shape)
channel_wise = tf.TensorArray(dtype=tf.float32, size=(shape[-1]))
for i in range(shape[-1]): # last index in shape should be the output channels of the last conv
channel_wise = channel_wise.write(i, self._linearLayer(encoded[:,:,i], shape[1], shape[1]*4,
name='Channel-wise' + str(i), isTraining=isTraining))
channel_wise = channel_wise.concat()
reshape = tf.reshape(channel_wise, [shape[0], shape[1]*4, shape[-1]])
reconstructed = self._decoder(reshape, isTraining)
return reconstructed
那么,关于为什么这需要这么长时间的任何想法?在实践中这是一个范围(2048),但所有线性层都非常小(4x16)。我是不是走错了路?
谢谢!
【问题讨论】:
标签: python tensorflow deep-learning autoencoder