MCPcopy Create free account
hub / github.com/apple/ml-pointersect / NetworkGraves

Class NetworkGraves

cdslib/core/nn/modules/graves.py:162–565  ·  view source on GitHub ↗

The Alex Graves' model in https://arxiv.org/abs/1308.0850 The network includes (see Fig 12 in the paper): - attn_rnn - gaussian sliding window attention - decode_rnn - output layer It does not include (since they are application-independent): - loss - samplin

Source from the content-addressed store, hash-verified

160
161
162class NetworkGraves(nn.Module):
163 """
164 The Alex Graves' model in https://arxiv.org/abs/1308.0850
165
166 The network includes (see Fig 12 in the paper):
167
168 - attn_rnn
169 - gaussian sliding window attention
170 - decode_rnn
171 - output layer
172
173 It does not include (since they are application-independent):
174
175 - loss
176 - sampling method
177
178 Methods:
179 1. forward
180
181 - inputs:
182
183 - [x0, x1, ..., x_{T-1}]
184 - [c1, c2, ..., cN]
185 - initial hidden states
186 - (optional) zt_fun that generates zt from current states
187
188 - outputs:
189
190 - [p1, p2, ..., p_T]
191 - [\hat{c1}, ... \hat{cT}]
192 - final hidden states
193
194 2. get_all_zero_hidden_states
195
196 """
197
198 def __init__(self, param_dict: ParamGraves = None, **kwargs):
199 """Create an Alex Graves' model.
200
201 Args:
202 param_dict:
203 A :py:class:`ParamGraves` object to define the hyper-parameters of the network.
204 kwargs:
205 If param_dict is None, you can directly provide keyword arguments of :py:class:`ParamGraves` here.
206 """
207 super().__init__()
208
209 # read and set configs
210 if param_dict is not None:
211 self.config_dict = ParamGraves(**param_dict)
212 else:
213 self.config_dict = ParamGraves(**kwargs)
214
215 for key in self.config_dict:
216 setattr(self, key, self.config_dict[key])
217
218 # construct sub-networks
219 self._construct_networks()

Callers 2

_build_modelMethod · 0.90
_construct_networksMethod · 0.85

Calls

no outgoing calls

Tested by 1

_build_modelMethod · 0.72