The document of mx.symbol.UpSampling was ambiguous. With several attempts, I found that the following code would produce a result successfully by chance. By the way, I realized that the weights for bilinear up-sampling needs to be defined explicitly, however this was not mentioned in the document.
The codes:
import mxnet as mx
import numpy as np
a = mx.sym.Variable('a')
a_nd = mx.nd.ones((10, 5, 8, 8), ctx=mx.gpu())
w = mx.sym.Variable('w')
w_np = np.zeros((5, 1, 4, 4))
w_np[:, :, [0, -1, 0, -1], [0, -1, -1, 0]] = 1.0
w_nd = mx.nd.array(w_np, ctx=mx.gpu())
b = mx.sym.UpSampling(a, w, num_args=2, scale=2, sample_type='bilinear', num_filter=5)
exe1 = b.bind(ctx=mx.gpu(), args={'a':a_nd, 'w':w_nd})
exe1.forward()
print exe1.outputs[0].asnumpy().shape
print exe1.outputs[0].asnumpy()
Sometimes this raises an error:
src/operator/./deconvolution-inl.h:75: Check failed: pad_y >= target_shape[0] (18 vs. 1537294416) too big target shape
The number in bold varies! Here goes error information in other attempts:
- pad_y >= target_shape[0] (18 vs. 31615648)
- pad_y >= target_shape[0] (18 vs. 528347216)
- pad_y >= target_shape[0] (18 vs. 40733264)
Sometimes the program produce a result:
(10, 5, 16, 16)
[[[[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 1. 1. ..., 1. 1. 0.]
[ 0. 1. 1. ..., 1. 1. 0.]
...,
...,
[ 0. 1. 1. ..., 1. 1. 0.]
[ 0. 1. 1. ..., 1. 1. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]]]]
Is this a bug?
The document of
mx.symbol.UpSamplingwas ambiguous. With several attempts, I found that the following code would produce a result successfully by chance. By the way, I realized that the weights for bilinear up-sampling needs to be defined explicitly, however this was not mentioned in the document.The codes:
Sometimes this raises an error:
src/operator/./deconvolution-inl.h:75: Check failed: pad_y >= target_shape[0] (18 vs. 1537294416) too big target shape
The number in bold varies! Here goes error information in other attempts:
Sometimes the program produce a result:
Is this a bug?