File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -140,12 +140,12 @@ Jacobian descent using [UPGrad](https://torchjd.org/stable/docs/aggregation/upgr
140140+ engine = Engine(model.modules())
141141
142142 inputs = torch.randn(8, 16, 10) # 8 batches of 16 random input vectors of length 10
143- targets = torch.randn(8, 16, 1 ) # 8 batches of 16 targets for the first task
143+ targets = torch.randn(8, 16) # 8 batches of 16 targets for the first task
144144
145145 for input, target in zip(inputs, targets):
146- output = model(input)
147- - loss = loss_fn(output, target)
148- + losses = loss_fn(output, target)
146+ output = model(input).squeeze(dim=1) # shape [16]
147+ - loss = loss_fn(output, target) # shape [1]
148+ + losses = loss_fn(output, target) # shape [16]
149149
150150 optimizer.zero_grad()
151151- loss.backward()
You can’t perform that action at this time.
0 commit comments