The problem is that you are adding a dimension at the end. expand now only adds new dimensions up front (http://pytorch.org/docs/master/tensors.html#torch.Tensor.expand 260), being consistent with numpy’s broadcasting rules. What you can do is to first unsqueeze to add a dimension, and then expand. (At least) two ways to do this:

Numpy-style broadcasting: A[:, :, None].expand(256, 15, 24)

Explicit unsqueeze: A.unsqueeze(-1).expand(256, 15, 24)