(self, x, hx=None, cx=None, seq_lengths=None)
| 1595 | self.cudnn_rnn_mode = 3 |
| 1596 | |
| 1597 | def initialize(self, x, hx=None, cx=None, seq_lengths=None): |
| 1598 | if self.batch_first: |
| 1599 | x = x.transpose((1, 0, 2)) |
| 1600 | self.input_size = x.shape[1] |
| 1601 | |
| 1602 | # GPU handle |
| 1603 | self.handle = singa.CudnnRNNHandle(x.data, |
| 1604 | self.hidden_size, |
| 1605 | mode=self.cudnn_rnn_mode, |
| 1606 | num_layers=self.num_layers, |
| 1607 | dropout=self.dropout, |
| 1608 | bidirectional=self.bidirectional) |
| 1609 | |
| 1610 | self.W = Tensor(shape=(self.handle.weights_size,), |
| 1611 | requires_grad=True, |
| 1612 | stores_grad=True, |
| 1613 | device=x.device) |
| 1614 | |
| 1615 | k = 1 / self.hidden_size |
| 1616 | self.W.uniform(-math.sqrt(k), math.sqrt(k)) |
| 1617 | |
| 1618 | def forward(self, x, hx=None, cx=None, seq_lengths=None): |
| 1619 |
nothing calls this directly
no test coverage detected