python - 如何在张量流中完全执行二维插值?
问题描述
我已经使用 scipy.interpolate 中的 RectBivariateSpline 方法成功地在 python 中执行了 2d 插值。但是,它是在 numpy 数组上执行的。我想仅使用 tensorflow 在张量上执行它。
这就是我现在所拥有的:如果都是 numpy 数组,它就可以工作。但是,我很难在 tensorflow 中重写它。
x_old = np.arange(0,256)
y_old = np.arange(0,256)
#x = tensor of shape [256,256]
#y = tensor of shape [256,256]
#in_im = tensor of shape [256,256,3]
#out_im = tensor of shape [256,256,3]
for d in range(0,3):
interpf = RectBivariateSpline( x_old, y_old, in_im[:,:,d])
out_im[:,:,d] = interpf.ev(x[:,:], y[:,:])
解决方案
tf.image 中的调整大小运算符可能是您正在寻找的,例如 tf.image.resize_bicubic ( https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/image/resize_bicubic )
推荐阅读
- python - 如何通过python连接到Oracle DB
- java - 收到错误 java.lang.ClassNotFoundException: AppLoader
- php - 此 SQL 中需要什么 id 来显示表中的学生信息?
- vba - 如何激活excelsheet而不在vba中打开它?
- c++ - boost::gil::resize_view 在创建迭代器时出现段错误
- c# - 这怎么可能是同一个sql连接?
- swift - 快速查找字符串的最后一个索引
- sql - Redshift - 聚合函数调用可能没有嵌套聚合或窗口函数
- cmake - Qt Creator:无法重命名文件
- ruby-on-rails - Capistrano + Digital Ocean + Rails:发生未处理的低级错误。应用程序日志可能包含详细信息