Commit Graph

33 Commits

Author SHA1 Message Date
Mike Sperber 568c9b6f03
Update to current proto-lens packages. (#258) 2020-05-21 13:36:52 -07:00
rschlotterbeck d741c3ee59 Add gradient for batchMatMul (#246) 2019-07-08 13:41:35 -04:00
rschlotterbeck c811037cb9 Add gradient for sigmoid (#245) 2019-07-07 20:18:02 -04:00
Christian Berentsen 1fbd5d41dd Add gradients for DepthwiseConv2dNative (#240) 2019-04-22 00:46:27 -04:00
Christian Berentsen 4a2e46ba57 Make 'mean' doubly differentiable (#241)
Use stopGradient on shape computations
Add opGrad for StopGradient
2019-04-22 00:46:01 -04:00
Daniel YU 7316062c10 upgrade to ghc 8.6.4 (#237) 2019-04-11 19:27:15 -07:00
Christian Berentsen c0f87dc0bc Avoid computing gradients for incidental nodes (#238) 2019-04-11 14:17:19 -04:00
Christian Berentsen 96f1c88327 Add gradient for ResizeBilinear (#239) 2019-04-08 13:43:17 -04:00
erikabor 3cfd96ef08 Add gradient for slice function (#234) 2019-03-26 16:30:50 -04:00
erikabor 666dce94bd Add gradient for sqrt function (#236) 2019-03-18 21:08:08 -04:00
Rik e4acd69574 Support gradients of pad, squeeze, spaceToBatchND, and batchToSpaceND (#226) 2018-11-27 14:17:32 -05:00
Rik 95c6b6f277 Added support for ExpandDims gradient. (#224) 2018-11-20 21:45:31 -05:00
Rik 915015018c Added support for tanh activation function (#223) 2018-11-14 12:08:05 -05:00
Christian Berentsen 61e58fd33f Use proto-lens* == 0.3.* (#212)
* Include more *_Fields modules
2018-09-04 10:44:52 -07:00
Christian Berentsen 2dcc921f6e Gradient of Conv2DBackpropInput (#155) 2017-10-15 11:49:44 -07:00
Nathan T.A. Lewis d79a919efa Fix a small typo in the warning message of numOutputs (#151) 2017-08-24 17:34:22 -04:00
Jonathan Kochems 79d8d7edea Adding gradient for Concat (#144) 2017-07-29 23:29:33 -04:00
fkm3 cac45d1cd6 Delete inaccurate comments 2017-07-25 09:38:00 -04:00
Christian Berentsen bebc4aa7d9 Add gradient of 'maximum' and 'gradForBinaryCwise'
`maximum` gradient uses `gradForBinaryCwise` which may be useful for other
binary componentwise op gradients
2017-07-25 00:14:23 -04:00
Christian Berentsen ea30577264 Gradient for AddN 2017-07-25 00:06:10 -04:00
fkm3 0603a6987b Add Minimize module with gradient descent and adam implementations (#125) 2017-05-25 19:19:22 -07:00
fkm3 b86945f008 Support Variable in TensorFlow.Gradient and use in mnist example (#116) 2017-05-17 13:20:51 -07:00
fkm3 0f04e5a50d Expand Rendered class to support ResourceHandle wrappers like Variable
This allows functions like `feed`, `colocateWith`, and (in a later commit)
`gradients` to work with `Variable`.
2017-05-15 19:55:34 -07:00
Jarl Christian Berentsen d153d0aded Fixed matMul gradients for transposed arguments 2017-05-05 16:49:27 -07:00
Jarl Christian Berentsen 51014a015c Implemented TileGrad
Some notes about static shape inference
2017-05-05 16:49:27 -07:00
Christian Berentsen eca4ff8981 Implemented ReluGradGrad and FillGrad (#102)
Added testReluGrad, testReluGradGrad and testFillGrad
2017-04-30 11:18:06 -07:00
Judah Jacobson d62c614695 Distinguish between "rendered" and "unrendered" Tensors. (#88)
Distinguish between "rendered" and "unrendered" Tensors.

There are now three types of `Tensor`:

- `Tensor Value a`: rendered value
- `Tensor Ref a`: rendered reference
- `Tensor Build a` : unrendered value

The extra bookkeeping makes it easier to track (and enforce) which tensors are
rendered or not.  For examples where this has been confusing in the past, see

With this change, pure ops look similar to before, returning `Tensor Build`
instead of `Tensor Value`.  "Stateful" (monadic) ops are unchanged.  For
example:

    add :: OneOf [..] t => Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
    assign :: (MonadBuild m, TensorType t)
           => Tensor Ref t -> Tensor v'2 t -> m (Tensor Ref t)

The `gradients` function now requires that the variables over which it's
differentiating are pre-rendered:

    gradients :: (..., Rendered v2) => Tensor v1 a -> [Tensor v2 a]
              -> m [Tensor Value a]

(`Rendered v2` means that `v2` is either a `Ref` or a `Value`.)

Additionally, the implementation of `gradients` now takes care to render every
intermediate value when performing the reverse accumulation.  I suspect this
fixes an exponential blowup for complicated expressions.
2017-04-06 15:10:33 -07:00
Judah Jacobson c99a23b6a7 Add versions of each op that take optional params as an extra arg. (#84)
Each op `foo :: ...` now has a corresponding `foo' :: OpParams -> ...`
which lets you set optional attributes.  `OpParams` is currently a type alias for
`OpDef -> OpDef`.  In the future we should consider more type safety, e.g.,
using type-level strings and OverloadedLabels for optional attributes.

I used it to replace a few manual `buildOp`s in our code with the codegenerated
ops, now that it's easier to set attributes.  I also removed `tensorAttr` and
`named` since it's now possible to set those op attributes directly.

Although this clutters up the API a bit, I think it's simpler than using type
classes to implement optional arguments (as in, for example, `Text.Printf`) --
especially in terms of type inference with the rest of the library.
2017-03-20 18:16:38 -07:00
Judah Jacobson 2c5c879037 Introduce a MonadBuild class, and remove `buildAnd`. (#83)
This change adds a class that both `Build` and `Session` are instances of:

    class MonadBuild m where
        build :: Build a -> m a

All stateful ops (generated and manually written) now have a signature that returns
an instance of `MonadBuild` (rather than just `Build`).  For example:

    assign_ :: (MonadBuild m, TensorType t)
            => Tensor Ref t -> Tensor v t -> m (Tensor Ref t)

This lets us remove a bunch of spurious calls to `build` in user code.  It also
lets us replace the pattern `buildAnd run foo` with the simpler pattern `foo >>= run`
(or `run =<< foo`, which is sometimes nicer when foo is a complicated expression).

I went ahead and deleted `buildAnd` altogether since it seems to lead to
confusion; in particular a few tests had `buildAnd run . pure` which is
actually equivalent to just `run`.
2017-03-18 12:08:53 -07:00
fkm3 cc08520dc7 Fix gradients calculation for min and max (#48) 2016-12-12 09:47:02 -08:00
Greg Steuck 2b5e41ffeb Make code --pedantic (#35)
* Enforce pedantic build mode in CI.
* Our imports drifted really far from where they should be.
2016-11-18 10:42:02 -08:00
Noon van der Silk 69fdbf677f test case to show can't calculate grad for embedding (and associated fix) (#23)
* Fix for embedding gradient calculation

- Passes vectors instead of scalars to slice
- converts the numRows to a scalar
- add `toScalar` utility function
- minor change to test case so that it actually works

* added lib for testing helper functions

* add flatSlice function
2016-11-17 13:54:36 -08:00
Greg Steuck 67690d1499 Initial commit 2016-10-24 19:26:42 +00:00