def h(sample): inputs = Variable(cast(sample[0], opt.dtype)) targets = Variable(cast(sample[1], 'long')) y = data_parallel(f, inputs, params, stats, sample[2], np.arange(opt.ngpu)) return F.cross_entropy(y, targets), y
def h(sample): inputs = cast(sample[0], opt.dtype) targets = cast(sample[1], 'long') y = data_parallel(f, inputs, params, sample[2], range(opt.ngpu)).float() return F.cross_entropy(y, targets), y