I’m a bit confused, as your first post mentioned you are using 1.4.0, while now you are downgrading PyTorch to 0.4.1 (or 0.3.1)?
Try to stick with 1.4.0 and either unsqueeze the tensor or don’t try to iterate a scalar value.