Skip to content

Commit

Permalink
try fix codacy issue of overload input in py3 (#459)
Browse files Browse the repository at this point in the history
* try fix codacy issue of overload input

* Update conv.py

* Update conv.py

* Update conv.py
  • Loading branch information
pmixer authored and haifeng-jin committed Jan 16, 2019
1 parent 48ab9b0 commit d873aa4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions autokeras/pretrained/voice_generator/deepvoice3_pytorch/conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ def __init__(self, *args, **kwargs):
self.clear_buffer()
self._linearized_weight = None

def incremental_forward(self, input):
def incremental_forward(self, input_data):

# reshape weight
weight = self._get_linearized_weight()
kw = self.kernel_size[0]
dilation = self.dilation[0]

bsz = input.size(0) # input: bsz x len x dim
bsz = input_data.size(0) # conv_input: bsz x len x dim
if kw > 1:
input = input.data
input_data = input_data.data
if self.input_buffer is None:
self.input_buffer = input.new(bsz, kw + (kw - 1) * (dilation - 1), input.size(2))
self.input_buffer = input_data.new(bsz, kw + (kw - 1) * (dilation - 1), input_data.size(2))
self.input_buffer.zero_()
else:
# shift buffer
self.input_buffer[:, :-1, :] = self.input_buffer[:, 1:, :].clone()
# append next input
self.input_buffer[:, -1, :] = input[:, -1, :]
input = self.input_buffer
self.input_buffer[:, -1, :] = input_data[:, -1, :]
input_data = self.input_buffer
if dilation > 1:
input = input[:, 0::dilation, :].contiguous()
output = F.linear(input.view(bsz, -1), weight, self.bias)
return output.view(bsz, 1, -1)
input_data = input_data[:, 0::dilation, :].contiguous()
input_data = F.linear(input_data.view(bsz, -1), weight, self.bias)
return input_data.view(bsz, 1, -1)

def clear_buffer(self):
self.input_buffer = None
Expand Down

0 comments on commit d873aa4

Please sign in to comment.