python - Tensorflow 层在矩阵维度和 Keras 等效项上的应用
问题描述
我有一个 TensorFlow 代码:
.
.
leaky_relu(tf.matmul(tf.transpose(out2, perm=[0, 2, 1, 3]), tf.transpose(out2, perm=[0, 2, 3, 1])))
.
.
在这里, 的输出tf.matmul
具有 的形状(4, 9, 9)
。然后我把它喂给leaky_relu
一层。
现在我的问题是,如果我使用 Keras 重写它,那么下面的“翻译”是否准确?
.
.
out2 = Lambda(lambda x: K.dot(K.permute_dimensions(x, (0, 2, 1, 3)), K.permute_dimensions(x, (0, 2, 3, 1))), output_shape=(4,9,9))(out2)
out2 = Flatten()(out2)
out2 = Dense(324, kernel_initializer='glorot_normal', activation='linear')(out2)
out2 = LeakyReLU(alpha=.2)(out2)
out2 = Reshape((4, 9, 9))(out2)
.
.
解决方案
推荐阅读
- vue.js - 在 Vue 组件中向 SVG 添加样式元素
- javascript - Firebase 使用电子邮件链接登录并在不同设备上进行验证
- javascript - 从 useEffect 返回的反应钩子之间的区别
- gam - 在 R 中导出 GAM 函数输出
- php - PHP cURL - 登录并使用 cookie 进行下次运行
- c# - 如何使用 API 为 Github 存储库启用页面
- tableau-api - 将聚合不同计数放入 else if tableau
- spring-integration - 如何在spring集成http入站适配器中验证传入的json并返回一个Json响应
- javascript - 仅在 TextInput 焦点/模糊上运行 Reanimated 动画
- javascript - 库存库存数据的 Mongo 聚合