Skip to content

Instantly share code, notes, and snippets.

@funrep

funrep/grad.hs Secret

Created May 22, 2020 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funrep/ced4c79fd97cbc945e8a5a83c4b30dc8 to your computer and use it in GitHub Desktop.
Save funrep/ced4c79fd97cbc945e8a5a83c4b30dc8 to your computer and use it in GitHub Desktop.
import Torch
import Torch.Autograd
main :: IO ()
main = do
let f = asTensor ([2.0] :: [Double])
x <- sequence . map makeIndependent $ [asTensor (1.0 :: Double), asTensor (2.0 :: Double)]
print $ requiresGrad f
print $ grad f x
@funrep
Copy link
Author

funrep commented May 22, 2020

False
foobar: CppStdException "Exception: Differentiated tensor not require grad; type: std::runtime_error"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment