Skip to content

Commit

Permalink
fixes #2967
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Nov 23, 2020
1 parent 61cf3e4 commit 5b6148e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ test:
nbdev_test_nbs --pause 0.5 --flags ''

testmore:
nbdev_test_nbs --pause 0.5 --flags 'cpp cuda'
nbdev_test_nbs --pause 0.5 --flags 'cpp cuda' --n_workers 8

testall:
nbdev_test_nbs --pause 0.5 --flags 'cpp cuda slow'
nbdev_test_nbs --pause 0.5 --flags 'cpp cuda slow' --n_workers 4

release: pypi
sleep 3
Expand Down
6 changes: 2 additions & 4 deletions fastai/text/models/qrnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ def forward(self, inp, hid=None):
y = self.linear(self._get_source(inp))
if self.output_gate: z_gate,f_gate,o_gate = y.chunk(3, dim=2)
else: z_gate,f_gate = y.chunk(2, dim=2)
z_gate.tanh_()
f_gate.sigmoid_()
z_gate,f_gate = z_gate.tanh(),f_gate.sigmoid()
if self.zoneout and self.training:
f_gate = f_gate * dropout_mask(f_gate, f_gate.size(), self.zoneout).requires_grad_(False)
z_gate,f_gate = z_gate.contiguous(),f_gate.contiguous()
f_gate *= dropout_mask(f_gate, f_gate.size(), self.zoneout).requires_grad_(False)
forget_mult = dispatch_cuda(ForgetMultGPU, partial(forget_mult_CPU), inp)
c_gate = forget_mult(z_gate, f_gate, hid, self.batch_first, self.backward)
output = torch.sigmoid(o_gate) * c_gate if self.output_gate else c_gate
Expand Down
3 changes: 3 additions & 0 deletions nbs/32_text.models.awdlstm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@
"text": [
"Converted 00_torch_core.ipynb.\n",
"Converted 01_layers.ipynb.\n",
"Converted 01a_losses.ipynb.\n",
"Converted 02_data.load.ipynb.\n",
"Converted 03_data.core.ipynb.\n",
"Converted 04_data.external.ipynb.\n",
Expand All @@ -539,6 +540,7 @@
"Converted 09b_vision.utils.ipynb.\n",
"Converted 09c_vision.widgets.ipynb.\n",
"Converted 10_tutorial.pets.ipynb.\n",
"Converted 10b_tutorial.albumentations.ipynb.\n",
"Converted 11_vision.models.xresnet.ipynb.\n",
"Converted 12_optimizer.ipynb.\n",
"Converted 13_callback.core.ipynb.\n",
Expand All @@ -552,6 +554,7 @@
"Converted 17_callback.tracker.ipynb.\n",
"Converted 18_callback.fp16.ipynb.\n",
"Converted 18a_callback.training.ipynb.\n",
"Converted 18b_callback.preds.ipynb.\n",
"Converted 19_callback.mixup.ipynb.\n",
"Converted 20_interpret.ipynb.\n",
"Converted 20a_distributed.ipynb.\n",
Expand Down
35 changes: 25 additions & 10 deletions nbs/36_text.models.qrnn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,9 @@
" y = self.linear(self._get_source(inp))\n",
" if self.output_gate: z_gate,f_gate,o_gate = y.chunk(3, dim=2)\n",
" else: z_gate,f_gate = y.chunk(2, dim=2)\n",
" z_gate.tanh_()\n",
" f_gate.sigmoid_()\n",
" z_gate,f_gate = z_gate.tanh(),f_gate.sigmoid()\n",
" if self.zoneout and self.training:\n",
" f_gate = f_gate * dropout_mask(f_gate, f_gate.size(), self.zoneout).requires_grad_(False)\n",
" z_gate,f_gate = z_gate.contiguous(),f_gate.contiguous()\n",
" f_gate *= dropout_mask(f_gate, f_gate.size(), self.zoneout).requires_grad_(False)\n",
" forget_mult = dispatch_cuda(ForgetMultGPU, partial(forget_mult_CPU), inp)\n",
" c_gate = forget_mult(z_gate, f_gate, hid, self.batch_first, self.backward)\n",
" output = torch.sigmoid(o_gate) * c_gate if self.output_gate else c_gate\n",
Expand Down Expand Up @@ -477,6 +475,7 @@
"text": [
"Converted 00_torch_core.ipynb.\n",
"Converted 01_layers.ipynb.\n",
"Converted 01a_losses.ipynb.\n",
"Converted 02_data.load.ipynb.\n",
"Converted 03_data.core.ipynb.\n",
"Converted 04_data.external.ipynb.\n",
Expand All @@ -488,23 +487,28 @@
"Converted 09b_vision.utils.ipynb.\n",
"Converted 09c_vision.widgets.ipynb.\n",
"Converted 10_tutorial.pets.ipynb.\n",
"Converted 10b_tutorial.albumentations.ipynb.\n",
"Converted 11_vision.models.xresnet.ipynb.\n",
"Converted 12_optimizer.ipynb.\n",
"Converted 13_learner.ipynb.\n",
"Converted 13a_metrics.ipynb.\n",
"Converted 13_callback.core.ipynb.\n",
"Converted 13a_learner.ipynb.\n",
"Converted 13b_metrics.ipynb.\n",
"Converted 14_callback.schedule.ipynb.\n",
"Converted 14a_callback.data.ipynb.\n",
"Converted 15_callback.hook.ipynb.\n",
"Converted 15a_vision.models.unet.ipynb.\n",
"Converted 16_callback.progress.ipynb.\n",
"Converted 17_callback.tracker.ipynb.\n",
"Converted 18_callback.fp16.ipynb.\n",
"Converted 18a_callback.training.ipynb.\n",
"Converted 18b_callback.preds.ipynb.\n",
"Converted 19_callback.mixup.ipynb.\n",
"Converted 20_interpret.ipynb.\n",
"Converted 20a_distributed.ipynb.\n",
"Converted 21_vision.learner.ipynb.\n",
"Converted 22_tutorial.imagenette.ipynb.\n",
"Converted 23_tutorial.transfer_learning.ipynb.\n",
"Converted 23_tutorial.vision.ipynb.\n",
"Converted 24_tutorial.siamese.ipynb.\n",
"Converted 24_vision.gan.ipynb.\n",
"Converted 30_text.core.ipynb.\n",
"Converted 31_text.data.ipynb.\n",
Expand All @@ -514,19 +518,30 @@
"Converted 35_tutorial.wikitext.ipynb.\n",
"Converted 36_text.models.qrnn.ipynb.\n",
"Converted 37_text.learner.ipynb.\n",
"Converted 38_tutorial.ulmfit.ipynb.\n",
"Converted 38_tutorial.text.ipynb.\n",
"Converted 39_tutorial.transformers.ipynb.\n",
"Converted 40_tabular.core.ipynb.\n",
"Converted 41_tabular.data.ipynb.\n",
"Converted 42_tabular.model.ipynb.\n",
"Converted 43_tabular.learner.ipynb.\n",
"Converted 44_tutorial.tabular.ipynb.\n",
"Converted 45_collab.ipynb.\n",
"Converted 50_datablock_examples.ipynb.\n",
"Converted 46_tutorial.collab.ipynb.\n",
"Converted 50_tutorial.datablock.ipynb.\n",
"Converted 60_medical.imaging.ipynb.\n",
"Converted 61_tutorial.medical_imaging.ipynb.\n",
"Converted 65_medical.text.ipynb.\n",
"Converted 70_callback.wandb.ipynb.\n",
"Converted 71_callback.tensorboard.ipynb.\n",
"Converted 72_callback.neptune.ipynb.\n",
"Converted 73_callback.captum.ipynb.\n",
"Converted 74_callback.cutmix.ipynb.\n",
"Converted 97_test_utils.ipynb.\n",
"Converted index.ipynb.\n"
"Converted 99_pytorch_doc.ipynb.\n",
"Converted dev-setup.ipynb.\n",
"Converted index.ipynb.\n",
"Converted quick_start.ipynb.\n",
"Converted tutorial.ipynb.\n"
]
}
],
Expand Down

0 comments on commit 5b6148e

Please sign in to comment.