Commit Graph

17 Commits

Author SHA1 Message Date
James Cross
2c190d2f05 update transformer code for layer_norm() API change
Summary: Quick fix for unit test broken by D6454290. This is my fault for approving while the tests covering the single callsite were broken.

Reviewed By: goldsborough

Differential Revision: D6466566

fbshipit-source-id: 2683be3d6bb184286e64fbde3e572946e39030c7
2017-12-01 20:19:31 -08:00
Peter Goldsborough
b43c1b2bed Fix and upgrade brew.layer_norm
Summary:
While working on layer normalization for LSTMs I encountered an issue where the layer norm parameters (which are the scale/gain and bias/shift from the paper) were not registered in the model for `brew.layer_norm`. salexspb explained that this is because it was using the `init_net_param` API instead of `create_param`. This diff fixes this.

While fixing I noticed that I noticed that `brew.layer_norm` actually had a bug where it was multiplying with the bias instead of adding it. Another issue was that the function giving the scale and bias a shape of `[1]`, however the paper (https://arxiv.org/pdf/1607.06450.pdf) specifies that, like for batch norm, there is one scale and bias parameter per neuron, i.e. the shape should be `[1, axis_dimension]`. The API now takes an explicit `dim_in` parameter (also more consistent with other normalization functions in that module) so that this can be specified. See tests for how this now looks.

Reviewed By: jhcross

Differential Revision: D6454290

fbshipit-source-id: fc00ca614de3190c40ab743e8984bec9e85fb58c
2017-12-01 14:18:28 -08:00
Aapo Kyrola
14f95c2782 Updated brew SpatialBN to use initializers
Summary: Updated brew SpatialBN to use initializers similar to other brew ops such as conv and fc instead of initilaizing all of its parameters itself within the brew call.

Reviewed By: asaadaldien

Differential Revision: D5840359

fbshipit-source-id: 9f3d688d4957605eaf7ecd2488bc26bfb1da3f78
2017-11-02 11:25:45 -07:00
Yangqing Jia
8286ce1e3a Re-license to Apache
Summary: Closes https://github.com/caffe2/caffe2/pull/1260

Differential Revision: D5906739

Pulled By: Yangqing

fbshipit-source-id: e482ba9ba60b5337d9165f28f7ec68d4518a0902
2017-09-28 16:22:00 -07:00
James Reed
f388135d3f Layer norm brew wrapper
Summary: Implement a brew wrapper for the LayerNorm op. This adds the scalar weight and bias terms to the op.

Reviewed By: jmp84

Differential Revision: D5595836

fbshipit-source-id: 467b2e1158b0c454a149d4b26c47719826e98752
2017-08-17 11:17:47 -07:00
Simon Layton
ded2a5899e Option to set BN scale and bias initial values
Summary:
Necessary to reproduce setup from 1-hour imagenet paper
Closes https://github.com/caffe2/caffe2/pull/995

Differential Revision: D5547666

Pulled By: akyrola

fbshipit-source-id: cbd4396888b02f32c67e1fe7e53636329de64f1b
2017-08-02 11:38:57 -07:00
Andrey Malevich
a8fb85797c Refactoring of the parameters step 0. Add simple tags and unify interface for params and computed_params.
Summary:
This diff is the first step in the effort for refactoring all parameters. As a first step - I'm merging concept of params and computed_params, that is going
to be based on tags instead (in the first version it's still using old data structs to store all the BlobReferences).

Renaming computed_params to non-trainable/non-backprop params should be done is some other diff.

Reviewed By: salexspb

Differential Revision: D5171159

fbshipit-source-id: 68031ca779f053fb266a7c4a2e5b482a3bd9c832
2017-06-02 17:17:57 -07:00
Aapo Kyrola
076376f4f6 Revert D5119830: [C2] Refactoring of the parameters step 0. Add simple tags and unify interface for params and computed_params
Summary: This reverts commit 2001090a37346eb12abbb234e13e727c288eb8a7

Differential Revision: D5119830

fbshipit-source-id: bf321868338f0db85dff3237af7eaf74212dbdf6
2017-06-01 00:02:21 -07:00
Andrey Malevich
ff61ed358e Refactoring of the parameters step 0. Add simple tags and unify interface for params and computed_params
Summary:
This diff is the first step in the effort for refactoring all paramters. As a
first step - I'm merging concept of params and computed_params, that is going
to be based on tags instead (in the first version it's still using old data
structs to store all the BlobReferences).

Renaming computed_params to non-trainable/non-backprop params should be done is
some other diff.

Reviewed By: salexspb

Differential Revision: D5119830

fbshipit-source-id: 2001090a37346eb12abbb234e13e727c288eb8a7
2017-05-31 22:36:36 -07:00
Simon Layton
193c9289f0 Fix LRN schema for cuDNN op
Summary:
Correct schema generation was previously broken leading to invalid gradient op creation.

Also exhibited in model_device_helper, where invalid schema were being created on the CPU when kwargs['engine'] == 'CUDNN'
Closes https://github.com/caffe2/caffe2/pull/617

Reviewed By: asaadaldien

Differential Revision: D5097062

Pulled By: akyrola

fbshipit-source-id: e22181f857deccb7b4395e87271e2cbf1226eb64
2017-05-22 08:33:34 -07:00
Yiming Wu
a28b01c155 rnn with brew
Summary:
Update rnn_cell.py and char_rnn.py example with new `brew` model.

- Deprecated CNNModelHelper
- replace all helper functions with brew helper functions
- Use `model.net.<SingleOp>` format to create bare bone Operator for better clarity.

Reviewed By: salexspb

Differential Revision: D5062963

fbshipit-source-id: 254f7b9059a29621027d2b09e932f3f81db2e0ce
2017-05-16 13:33:44 -07:00
Simon Layton
1d0ba2cfbd New cudnn ops
Summary:
cuDNN versions of dropout and LRN (for native fp16 support), port of Caffe's max pooling algo that uses an explicit mask to store locations (also supports fp16 storage)
Closes https://github.com/caffe2/caffe2/pull/396

Reviewed By: akyrola

Differential Revision: D4990880

Pulled By: asaadaldien

fbshipit-source-id: a716acffb656843e9b31e3e6808bd2d8aa959d03
2017-05-08 16:33:21 -07:00
Yiming Wu
aa5a46b848 fix LRN order
Summary: fix LRN helper's order

Reviewed By: salexspb

Differential Revision: D4949902

fbshipit-source-id: 88b1aa985546d36aa66c0677c617979ff186d78a
2017-04-27 16:46:47 -07:00
Yiming Wu
0bb558716a rename model_helpers to brew and lowercase all helper functions
Summary:
rename model_helpers to brew. This is a big diff now. I did these things:

1. replace model_helpers with brew:

  find . -type f -exec sed -i 's/model_helpers/brew/g' {} +

2. rename model_helpers.py and model_helpers_test.py
3. rename ModelHelpersTest to BrewTest
4. lowercase all the helper functions to distinguish them from single op
5. run my unittests
6. run converge tests

Reviewed By: salexspb

Differential Revision: D4930465

fbshipit-source-id: f420a1b03238df1cbe9f4426e0b9c43a12119661
2017-04-24 15:52:26 -07:00
Yiming Wu
3623c241c4 normalization helpers
Summary: Add normalization helpers

Reviewed By: salexspb

Differential Revision: D4884786

fbshipit-source-id: 529e678bae133e85d981310014c15d551d39d48b
2017-04-17 15:03:04 -07:00
Aapo Kyrola
580ff3a594 Revert D4854240: [EAZY][C2 OSS] Add normalization helpers and proxy to CNNModelHelper
Summary: This reverts commit 3fa594d79960742b34e20d843e8b6ef8aeb601d3

Differential Revision: D4854240

fbshipit-source-id: d08cb30f188f876e1962f53a44f4e6d4ea68297f
2017-04-12 16:46:01 -07:00
Yiming Wu
b8f2baec8e Add normalization helpers and proxy to CNNModelHelper
Summary: Add normalization helpers and proxy to CNNModelHelper

Reviewed By: salexspb

Differential Revision: D4854240

fbshipit-source-id: 3fa594d79960742b34e20d843e8b6ef8aeb601d3
2017-04-11 23:02:59 -07:00