leezu commented on issue #18382:
URL:
https://github.com/apache/incubator-mxnet/issues/18382#issuecomment-636108998
@zhreshold there seem to be more issues with the test
```
[2020-05-29T14:10:33.690Z] _________________________________ test_CSVIter
_________________________________
[2020-05-29T14:10:33.690Z] [gw0] linux -- Python 3.6.9
/opt/rh/rh-python36/root/usr/bin/python
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] tmpdir =
local('/tmp/pytest-of-jenkins_slave/pytest-0/popen-gw0/test_CSVIter0')
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] def test_CSVIter(tmpdir):
[2020-05-29T14:10:33.690Z] def
check_CSVIter_synthetic(dtype='float32'):
[2020-05-29T14:10:33.690Z] data_path = os.path.join(str(tmpdir),
'data.t')
[2020-05-29T14:10:33.690Z] label_path =
os.path.join(str(tmpdir), 'label.t')
[2020-05-29T14:10:33.690Z] entry_str = '1'
[2020-05-29T14:10:33.690Z] if dtype is 'int32':
[2020-05-29T14:10:33.690Z] entry_str = '200000001'
[2020-05-29T14:10:33.690Z] if dtype is 'int64':
[2020-05-29T14:10:33.690Z] entry_str = '2147483648'
[2020-05-29T14:10:33.690Z] with open(data_path, 'w') as fout:
[2020-05-29T14:10:33.690Z] for i in range(1000):
[2020-05-29T14:10:33.690Z]
fout.write(','.join([entry_str for _ in range(8*8)]) + '\n')
[2020-05-29T14:10:33.690Z] with open(label_path, 'w') as fout:
[2020-05-29T14:10:33.690Z] for i in range(1000):
[2020-05-29T14:10:33.690Z] fout.write('0\n')
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] data_train =
mx.io.CSVIter(data_csv=data_path, data_shape=(8, 8),
[2020-05-29T14:10:33.690Z]
label_csv=label_path, batch_size=100, dtype=dtype)
[2020-05-29T14:10:33.690Z] expected = mx.nd.ones((100, 8, 8),
dtype=dtype) * int(entry_str)
[2020-05-29T14:10:33.690Z] for batch in iter(data_train):
[2020-05-29T14:10:33.690Z] data_batch = data_train.getdata()
[2020-05-29T14:10:33.690Z]
assert_almost_equal(data_batch.asnumpy(), expected.asnumpy())
[2020-05-29T14:10:33.690Z] assert data_batch.asnumpy().dtype
== expected.asnumpy().dtype
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] for dtype in ['int32', 'int64',
'float32']:
[2020-05-29T14:10:33.690Z] > check_CSVIter_synthetic(dtype=dtype)
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] tests/python/unittest/test_io.py:452:
[2020-05-29T14:10:33.690Z] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[2020-05-29T14:10:33.690Z] tests/python/unittest/test_io.py:448: in
check_CSVIter_synthetic
[2020-05-29T14:10:33.690Z] assert_almost_equal(data_batch.asnumpy(),
expected.asnumpy())
[2020-05-29T14:10:33.690Z] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] a = array([[[2147483648, 47483648, 47483648,
..., 47483648,
[2020-05-29T14:10:33.690Z] 47483648, 47483648],
[2020-05-29T14:10:33.690Z] [ 47483648, ...7483648, 47483648],
[2020-05-29T14:10:33.690Z] [ 47483648, 47483648, 47483648, ...,
47483648,
[2020-05-29T14:10:33.690Z] 47483648, 47483648]]])
[2020-05-29T14:10:33.690Z] b = array([[[2147483648, 2147483648, 2147483648,
..., 2147483648,
[2020-05-29T14:10:33.690Z] 2147483648, 2147483648],
[2020-05-29T14:10:33.690Z] [2147483648, 2...7483648, 2147483648],
[2020-05-29T14:10:33.690Z] [2147483648, 2147483648, 2147483648, ...,
2147483648,
[2020-05-29T14:10:33.690Z] 2147483648, 2147483648]]])
[2020-05-29T14:10:33.690Z] rtol = 1e-05, atol = 1e-20, names = ('a', 'b'),
equal_nan = False
[2020-05-29T14:10:33.690Z] use_broadcast = True, mismatches = (10, 10)
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] def assert_almost_equal(a, b, rtol=None,
atol=None, names=('a', 'b'), equal_nan=False,
[2020-05-29T14:10:33.690Z] use_broadcast=True,
mismatches=(10, 10)):
[2020-05-29T14:10:33.690Z] """Test that two numpy arrays are almost
equal. Raise exception message if not.
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] Parameters
[2020-05-29T14:10:33.690Z] ----------
[2020-05-29T14:10:33.690Z] a : np.ndarray or mx.nd.array
[2020-05-29T14:10:33.690Z] b : np.ndarray or mx.nd.array
[2020-05-29T14:10:33.690Z] rtol : None or float
[2020-05-29T14:10:33.690Z] The relative threshold. Default
threshold will be used if set to ``None``.
[2020-05-29T14:10:33.690Z] atol : None or float
[2020-05-29T14:10:33.690Z] The absolute threshold. Default
threshold will be used if set to ``None``.
[2020-05-29T14:10:33.690Z] names : tuple of names, optional
[2020-05-29T14:10:33.690Z] The names used in error message when
an exception occurs
[2020-05-29T14:10:33.690Z] equal_nan : boolean, optional
[2020-05-29T14:10:33.690Z] The flag determining how to treat NAN
values in comparison
[2020-05-29T14:10:33.690Z] mismatches : tuple of mismatches
[2020-05-29T14:10:33.690Z] Maximum number of mismatches to be
printed (mismatches[0]) and determine (mismatches[1])
[2020-05-29T14:10:33.690Z] """
[2020-05-29T14:10:33.690Z] if not use_broadcast:
[2020-05-29T14:10:33.690Z] checkShapes(a, b)
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] rtol = get_rtol(rtol)
[2020-05-29T14:10:33.690Z] atol = get_atol(atol)
[2020-05-29T14:10:33.690Z] use_np_allclose = isinstance(a,
np.ndarray) and isinstance(b, np.ndarray)
[2020-05-29T14:10:33.690Z] if not use_np_allclose:
[2020-05-29T14:10:33.690Z] if not (hasattr(a, 'ctx') and
hasattr(b, 'ctx') and a.ctx == b.ctx and a.dtype == b.dtype):
[2020-05-29T14:10:33.690Z] use_np_allclose = True
[2020-05-29T14:10:33.690Z] if isinstance(a, mx.nd.NDArray):
[2020-05-29T14:10:33.690Z] a = a.asnumpy()
[2020-05-29T14:10:33.690Z] if isinstance(b, mx.nd.NDArray):
[2020-05-29T14:10:33.690Z] b = b.asnumpy()
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] if use_np_allclose:
[2020-05-29T14:10:33.690Z] if hasattr(a, 'dtype') and a.dtype ==
np.bool_ and hasattr(b, 'dtype') and b.dtype == np.bool_:
[2020-05-29T14:10:33.690Z] np.testing.assert_equal(a, b)
[2020-05-29T14:10:33.690Z] return
[2020-05-29T14:10:33.690Z] if almost_equal(a, b, rtol, atol,
equal_nan=equal_nan):
[2020-05-29T14:10:33.690Z] return
[2020-05-29T14:10:33.690Z] else:
[2020-05-29T14:10:33.690Z] output = mx.nd.contrib.allclose(a, b,
rtol, atol, equal_nan)
[2020-05-29T14:10:33.690Z] if output.asnumpy() == 1:
[2020-05-29T14:10:33.690Z] return
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] a = a.asnumpy()
[2020-05-29T14:10:33.690Z] b = b.asnumpy()
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] index, rel = find_max_violation(a, b,
rtol, atol)
[2020-05-29T14:10:33.690Z] indexErr = index
[2020-05-29T14:10:33.690Z] relErr = rel
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] print('\n*** Maximum errors for vector of
size {}: rtol={}, atol={}\n'.format(a.size, rtol, atol))
[2020-05-29T14:10:33.690Z] aTmp = a.copy()
[2020-05-29T14:10:33.690Z] bTmp = b.copy()
[2020-05-29T14:10:33.690Z] i = 1
[2020-05-29T14:10:33.690Z] while i <= a.size:
[2020-05-29T14:10:33.690Z] if i <= mismatches[0]:
[2020-05-29T14:10:33.690Z] print("%3d: Error %f %s" %(i,
rel, locationError(a, b, index, names)))
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] aTmp[index] = bTmp[index] = 0
[2020-05-29T14:10:33.690Z] if almost_equal(aTmp, bTmp, rtol,
atol, equal_nan=equal_nan):
[2020-05-29T14:10:33.690Z] break
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] i += 1
[2020-05-29T14:10:33.690Z] if i <= mismatches[1] or
mismatches[1] <= 0:
[2020-05-29T14:10:33.690Z] index, rel =
find_max_violation(aTmp, bTmp, rtol, atol)
[2020-05-29T14:10:33.690Z] else:
[2020-05-29T14:10:33.690Z] break
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] mismatchDegree = "at least " if
mismatches[1] > 0 and i > mismatches[1] else ""
[2020-05-29T14:10:33.690Z] errMsg = "Error %f exceeds tolerance
rtol=%e, atol=%e (mismatch %s%f%%).\n%s" % \
[2020-05-29T14:10:33.690Z] (relErr, rtol, atol,
mismatchDegree, 100*i/a.size, \
[2020-05-29T14:10:33.690Z] locationError(a, b, indexErr,
names, maxError=True))
[2020-05-29T14:10:33.690Z] np.set_printoptions(threshold=4,
suppress=True)
[2020-05-29T14:10:33.690Z] msg = npt.build_err_msg([a, b],
err_msg=errMsg)
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] > raise AssertionError(msg)
[2020-05-29T14:10:33.690Z] E AssertionError:
[2020-05-29T14:10:33.690Z] E Items are not equal:
[2020-05-29T14:10:33.690Z] E Error 97788.870335 exceeds tolerance
rtol=1.000000e-05, atol=1.000000e-20 (mismatch at least 0.171875%).
[2020-05-29T14:10:33.690Z] E Location of maximum error: (0, 0, 1),
a=47483648.00000000, b=2147483648.00000000
[2020-05-29T14:10:33.690Z] E ACTUAL: array([[[2147483648, 47483648,
47483648, ..., 47483648,
[2020-05-29T14:10:33.690Z] E 47483648, 47483648],
[2020-05-29T14:10:33.690Z] E [ 47483648, 47483648,
47483648, ..., 47483648,...
[2020-05-29T14:10:33.690Z] E DESIRED: array([[[2147483648,
2147483648, 2147483648, ..., 2147483648,
[2020-05-29T14:10:33.690Z] E 2147483648, 2147483648],
[2020-05-29T14:10:33.690Z] E [2147483648, 2147483648,
2147483648, ..., 2147483648,...
[2020-05-29T14:10:33.690Z]
[2020-05-29T14:10:33.690Z] python/mxnet/test_utils.py:637: AssertionError
```
http://jenkins.mxnet-ci.amazon-ml.com/blue/rest/organizations/jenkins/pipelines/mxnet-validation/pipelines/centos-cpu/branches/PR-18435/runs/1/nodes/236/steps/284/log/?start=0
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]