tensorflow - 如何编写自定义 keras 层来重新采样 3D 体积?
问题描述
我(batch_size, height, width, depth, channel)
在网络中有一个张量(代表 3D 体积),需要重新采样。我正在考虑编写一个自定义 keras 层来做到这一点。
input = Input()
x = net(input) # another network
x = custom_resample_3d(...)(x)
x = ...
的输出net
让我们说(batch_size, 64, 64, 64, 1)
。我想调整张量的大小以(batch_size, 256, 256, 32, 1)
使用插值。
所以我最初的想法就像用scipy.ndimage.interpolation.zoom
.
class MyLayer(Layer):
def __init__(self, output_dim, **kwargs):
self.output_dim = output_dim
super(MyLayer, self).__init__(**kwargs)
def build(self, input_shape):
super(MyLayer, self).build(input_shape) # Be sure to call this at the end
def call(self, x):
return scipy.ndimage.interpolation.zoom(x, ...)
def compute_output_shape(self, input_shape):
return ...
有没有更好的方法呢?还是我需要将其转换keras tensor
为 numpy 数组,然后将其转换回张量?
解决方案
推荐阅读
- python - 将嵌套的 xml 标记加载到 BQ 数组类型中
- java - springboot:“附加位置”中的配置被“应用程序-{profile}”覆盖
- if-statement - 一个单元格中的 Google 表格条件格式文本会影响另一个单元格
- reactjs - 即使状态已更新,组件也不会重新渲染
- abap - 访问 ABAP CDS 视图的替代方法是什么?
- dialogflow-es - 我的对话流代理突然不匹配任何查询的意图
- python - 在 discord.py 的 on_user_update 事件中获取公会 ID
- google-cloud-platform - 谷歌云监控未触发事件
- android - PayUMoney- Android 删除 postCheckout 页面
- excel-formula - 使用间接复制工作表之间的单元格后无法保留数字格式