def test_upsample(self):
h, w = 5, 5
scale = 2
mat = np.random.rand(h, w).astype('float32')
inp = self.make_variable(mat)
inp = tf.reshape(inp, [1, h, w, 1])
output = BilinearUpSample('upsample', inp, scale)
res = self.run_variable(output)[0,:,:,0]
from skimage.transform import rescale
res2 = rescale(mat, scale)
diff = np.abs(res2 - res)
# not equivalent to rescale on edge?
diff[0,:] = 0
diff[:,0] = 0
if not diff.max() < 1e-4:
import IPython;
IPython.embed(config=IPython.terminal.ipapp.load_default_config())
self.assertTrue(diff.max() < 1e-4)
评论列表
文章目录