Hugging Face
Models
Datasets
Spaces
Community
Docs
Enterprise
Pricing
Log In
Sign Up
Spaces:
EasonYan
/
MTECBS
like
0
Sleeping
App
Files
Files
Community
Fetching metadata from the HF Docker repository...
cc9df09
MTECBS
/
utils
/
transform.py
yan123yan
first version
47fe089
about 1 year ago
raw
Copy download link
history
blame
Safe
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
)