torch/nn — pull request #7 by nicholas-leonard (2014-04-10 19:20:31+00:00)
Title: Batch LookupTable

The following changes are included in this pull request :
* Allows LookupTable to work with mini-batches.
* Adds some unit tests for LookupTable.
* Fixes some small issues with nn.Jacobian.
* Updates LookupTable documentation.
* Extends LookupTable with scaleUpdateByKey(inputKey) method.

This last change makes it easier for subclasses to scale the updates of each entry (indexed by key) using the counts of backwards passes affecting each key. So for example, a user could build her own nn.FairLookupTable with each update scaled inversely proportional to the amount of backward passes since the last update :
```lua
local FairLookupTable, parent = torch.class('nn.FairLookupTable', 'nn.LookupTable')

function FairLookupTable:scaleUpdateByKey(inputKey)
local nBackward = self.inputs[inputKey]
return 1/nBackward
end
```
Or if the gradients were already scaled by dividing these by the number of samples in the batch, then a user could implement this instead:
```lua
local FairLookupTable, parent = torch.class('nn.FairLookupTable', 'nn.LookupTable')

function FairLookupTable:scaleUpdateByKey(inputKey)
local nBackward = self.inputs[inputKey]
return self.nBackward/nBackward
end
```
Etc. Default is to just return a scale of 1 (no change to existing implementation).