Download utils/transform.py from EasonYan/MTECBS: direct link, hf CLI and curl.
- Browser
- Download file 225 Bytes
-
https://huggingface.co/spaces/EasonYan/MTECBS/resolve/main/utils/transform.py
- Command line
-
hf download hf://spaces/EasonYan/MTECBS/utils/transform.py
-
curl -L -o transform.py https://huggingface.co/spaces/EasonYan/MTECBS/resolve/main/utils/transform.py
225 Bytes
| import torch | |
| def compute_gradient(x, degree): | |
| gradients = [x] | |
| for i in range(degree): | |
| x = torch.diff(x, dim=-1, prepend=x[..., 0:1]) | |
| gradients.append(x) | |
| return torch.concatenate(gradients, dim=-1) |