Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tweaks to gp example, remove dhall-based configuration for examples d…
…irectory
  • Loading branch information
austinvhuang committed Dec 8, 2018
1 parent dcc639c commit f317c67
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 177 deletions.
26 changes: 19 additions & 7 deletions examples/experimental/gp/Main.hs
Expand Up @@ -23,11 +23,20 @@ import Kernels (kernel1d_rbf)
-- type NSamp = 5
-- xRange = [-4..4]

-- type GridDim = 7
-- type GridSize = 49
-- type NSamp = 5
-- xRange = [-3..3]

type GridDim = 5
type GridSize = 25
type NSamp = 3
xRange = [-2..2]

tst = do
foo <- makeGrid
pure $ fst foo

makeGrid :: IO (DoubleTensor '[GridSize], DoubleTensor '[GridSize])
makeGrid = do
x :: DoubleTensor '[GridSize] <- unsafeVector (fst <$> rngPairs)
Expand Down Expand Up @@ -85,18 +94,14 @@ testGetri = do
main = do
(x, y) <- makeGrid
let rbf = kernel1d_rbf 1.0 1.0 x y
putStrLn "Radial Basis Function Kernel Values"
print rbf
let mu = constant 0 :: DoubleTensor [GridDim, GridDim]
let cov = resizeAs rbf :: DoubleTensor [GridDim, GridDim]

putStrLn "\nCovariance Matrix"
putStrLn "\nReshaped as a Covariance Matrix"
print cov

putStrLn "\nGP Samples (cols = realizations)"
gen <- newRNG
mvnSamp :: DoubleTensor '[GridDim, NSamp] <- mvnCholesky gen cov
print mvnSamp

-- let (invX, invLU) = gesv (eye :: DoubleTensor '[GridDim, GridDim]) cov
-- putStrLn "\nCovariance Inverse X"
-- print invX
Expand All @@ -107,8 +112,15 @@ main = do
putStrLn "\nInv Covariance"
print invCov

putStrLn "\nCheck"
putStrLn "\nCheck Inversion Operation (should recover identity matrix)"
print $ invCov !*! cov

putStrLn "\nGP Samples (cols = realizations)"
gen <- newRNG
mvnSamp :: DoubleTensor '[GridDim, NSamp] <- mvnCholesky gen cov
print mvnSamp

putStrLn "Done"

tst
pure ()
9 changes: 0 additions & 9 deletions examples/hasktorch-examples.cabal
@@ -1,13 +1,4 @@
cabal-version: 2.2
-- * * * * * * * * * * * * WARNING * * * * * * * * * * * *
-- This file has been AUTO-GENERATED by dhall-to-cabal.
--
-- Do not edit it by hand, because your changes will be over-written!
--
-- Instead, edit the source Dhall file, namely
-- 'examples/hasktorch-examples.dhall', and re-generate this file by running
-- 'dhall-to-cabal -- examples/hasktorch-examples.dhall > hasktorch-examples.cabal'.
-- * * * * * * * * * * * * WARNING * * * * * * * * * * * *
name: hasktorch-examples
version: 0.0.1.0
license: BSD-3-Clause
Expand Down
161 changes: 0 additions & 161 deletions examples/hasktorch-examples.dhall

This file was deleted.

4 changes: 4 additions & 0 deletions indef/src/Torch/Indef/Static/Tensor.hs
Expand Up @@ -75,6 +75,10 @@ _expand r t = Dynamic._expand (asDynamic r) (asDynamic t)
-- | Static call to 'Dynamic._expandNd'
_expandNd rs os = Dynamic._expandNd (fmap asDynamic rs) (fmap asDynamic os)

-- In general recommend using resizeAs over other resize* functions-
-- these are not dimension safe and also type-invalidate the underlying tensor
-- properties after the mutation.

-- | Static call to 'Dynamic.resize_'
_resize t a b = Dynamic._resize (asDynamic t) a b >> pure ((asStatic . asDynamic) t)
-- | Static call to 'Dynamic.resize1d_'
Expand Down

0 comments on commit f317c67

Please sign in to comment.