转置卷积(反卷积)算术

我正在使用TensorFlow构建一个卷积神经网络。给定一个形状为 (none, 16, 16, 4, 192) 的张量,我希望执行一个转置卷积操作,得到形状为 (none, 32, 32, 7, 192) 的结果。

使用大小为 [2,2,4,192,192] 的滤波器和步长为 [2,2,1,1,1] 是否能产生我想要的输出形状?


回答:

是的,你几乎是正确的。

有一个小小的修正是,tf.nn.conv3d_transpose 期望输入格式为 NCDHWNDHWC(你的格式看起来是 NHWDC),并且滤波器形状应为 [depth, height, width, output_channels, in_channels]。这会影响 filterstride 中维度的顺序:

# 原始格式: NHWDC.original = tf.placeholder(dtype=tf.float32, shape=[None, 16, 16, 4, 192])print original.shape# 转换为 NDHWC 格式.input = tf.reshape(original, shape=[-1, 4, 16, 16, 192])print input.shape# 输入形状:  [batch, depth, height, width, in_channels].# 滤波器形状: [depth, height, width, output_channels, in_channels].# 输出形状: [batch, depth, height, width, output_channels].filter = tf.get_variable('filter', shape=[4, 2, 2, 192, 192], dtype=tf.float32)conv = tf.nn.conv3d_transpose(input,                              filter=filter,                              output_shape=[-1, 7, 32, 32, 192],                              strides=[1, 1, 2, 2, 1],                              padding='SAME')print conv.shapefinal = tf.reshape(conv, shape=[-1, 32, 32, 7, 192])print final.shape

输出结果为:

(?, 16, 16, 4, 192)(?, 4, 16, 16, 192)(?, 7, 32, 32, 192)(?, 32, 32, 7, 192)

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注