From 695bf1a1f64399cc2eba83932869de57ddccc373 Mon Sep 17 00:00:00 2001 From: Eren Golge Date: Thu, 31 Oct 2019 17:21:00 +0100 Subject: [PATCH] bug fix for illegal memory reach --- layers/common_layers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layers/common_layers.py b/layers/common_layers.py index 8ea54f0e..6ddd0b6b 100644 --- a/layers/common_layers.py +++ b/layers/common_layers.py @@ -127,7 +127,7 @@ class GravesAttention(nn.Module): def init_states(self, inputs): if self.J is None or inputs.shape[1] > self.J.shape[-1]: - self.J = torch.arange(0, inputs.shape[1]).expand_as(torch.Tensor(inputs.shape[0], self.K, inputs.shape[1])).to(inputs.device) + self.J = torch.arange(0, inputs.shape[1]).to(inputs.device).expand([inputs.shape[0], self.K, inputs.shape[1]]) self.attention_weights = torch.zeros(inputs.shape[0], inputs.shape[1]).to(inputs.device) self.mu_prev = torch.zeros(inputs.shape[0], self.K).to(inputs.device)