def setUp(self):
if self.shape is None:
if self.dtype == numpy.float16:
self.x = numpy.array([[-5, 1]], dtype=self.dtype)
else:
self.x = numpy.array([[-1000, 1]], dtype=self.dtype)
self.t = numpy.array([0], dtype=numpy.int32)
else:
self.x = numpy.random.uniform(-1, 1, self.shape).astype(self.dtype)
out_shape = (self.shape[0],) + self.shape[2:]
self.t = numpy.random.randint(0, 3, out_shape).astype(numpy.int32)
if (self.ignore_index is not None and
len(self.ignore_index) <= self.t.ndim):
self.t[self.ignore_index] = -1
self.check_forward_options = {}
self.check_backward_options = {'atol': 1e-4, 'rtol': 1e-3}
if self.dtype == numpy.float16:
self.check_forward_options = {'atol': 1e-4, 'rtol': 1e-3}
self.check_backward_options = {'atol': 5e-2, 'rtol': 1e-1}
test_softmax_cross_entropy.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录