Memory Wrap: an extension for image classification models
Project description
Installation
To install Memory Wrap run the following command:
pip install memorywrap
The library contains two main classes:
- MemoryWrapLayer: it is the Memory Wrap variant described in the paper that uses both the input encoding and the memory encoding to compute the output;
- BaselineMemory: it is the baseline that uses only the memory encoding to compute the output.
Usage
Instantiate the layer
memorywrap = MemoryWrapLayer(encoder_dim,output_dim,return_weights=False)
or
memorywrap = BaselineMemory(encoder_dim,output_dim)
where:
- encoder_dim is the output dimension of the last layer of the encoder
- output_dim is the desired output dimensione. In the case of the paper output_dim is equal to the number of classes;
- return_weights is a flag telling to the layer if it has to return the sparse content weights.
Forward pass
Add the forward call to your forward function.
output_memorywrap = memorywrap(input_encoding,memory_encoding)
where input_encoding and memory_encoding are the outputs of the the encoder of rispectively the current input and the memory set.
If you have set the flag return_weights to True, then output_memorywrap is a Tuple where the first element is the output and the second one are the content weights associated to each element in the memory_encoding.
Additional information
Here you can find link to additional source of information about Memory Wrap:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
memorywrap-1.0.1.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for memorywrap-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 292d8e48c5cbd72d477cfaba87fb6dabc36c94673a28d48afdd5fc204dcc69e6 |
|
MD5 | ffa6409296c26b863e7ccb07e853bc61 |
|
BLAKE2b-256 | 36e642679b60c1ebcd3738d442309a6d10c337dc25799e2939c171ca37d94e93 |