Commit 352aed53 authored by Francois Marelli's avatar Francois Marelli

better naming convention

parent 96a6087f
from .NeuralFilterCell import * from .neural_filter import *
from .NeuralFilter1P import * from .neural_filter_1L import *
from .NeuralFilter2R import * from .neural_filter_2R import *
from .NeuralFilter2CC import * from .neural_filter_2CC import *
from .NeuralFilter2CD import * from .neural_filter_2CD import *
from .LogMSELoss import * from .log_loss import *
...@@ -31,7 +31,7 @@ from torch.nn import functional as F ...@@ -31,7 +31,7 @@ from torch.nn import functional as F
import numpy as np import numpy as np
class NeuralFilterCell(torch.nn.Module): class NeuralFilter(torch.nn.Module):
""" """
A trainable first-order all-pole filter :math:`\\frac{1}{1 - P z^{-1}}` A trainable first-order all-pole filter :math:`\\frac{1}{1 - P z^{-1}}`
...@@ -39,7 +39,7 @@ class NeuralFilterCell(torch.nn.Module): ...@@ -39,7 +39,7 @@ class NeuralFilterCell(torch.nn.Module):
""" """
def __init__(self, hidden_size): def __init__(self, hidden_size):
super(NeuralFilterCell, self).__init__() super(NeuralFilter, self).__init__()
self.hidden_size = hidden_size self.hidden_size = hidden_size
......
...@@ -29,9 +29,9 @@ import torch ...@@ -29,9 +29,9 @@ import torch
from torch.nn import Parameter from torch.nn import Parameter
from torch.nn import functional as F from torch.nn import functional as F
import math import math
from . import NeuralFilterCell from . import NeuralFilter
class NeuralFilter1P(NeuralFilterCell): class NeuralFilter1L(NeuralFilter):
""" """
A trainable first-order all-pole filter :math:`\\frac{K}{1 - P z^{-1}}` with bias on the input A trainable first-order all-pole filter :math:`\\frac{K}{1 - P z^{-1}}` with bias on the input
...@@ -40,7 +40,7 @@ class NeuralFilter1P(NeuralFilterCell): ...@@ -40,7 +40,7 @@ class NeuralFilter1P(NeuralFilterCell):
""" """
def __init__(self, input_size, hidden_size): def __init__(self, input_size, hidden_size):
super(NeuralFilter1P, self).__init__(hidden_size) super(NeuralFilter1L, self).__init__(hidden_size)
self.input_size = input_size self.input_size = input_size
...@@ -58,7 +58,7 @@ class NeuralFilter1P(NeuralFilterCell): ...@@ -58,7 +58,7 @@ class NeuralFilter1P(NeuralFilterCell):
for weight in self.parameters(): for weight in self.parameters():
weight.data.uniform_(-stdv, stdv) weight.data.uniform_(-stdv, stdv)
super(NeuralFilter1P, self).reset_parameters(init) super(NeuralFilter1L, self).reset_parameters(init)
def check_forward_input(self, input): def check_forward_input(self, input):
if input.size(-1) != self.input_size: if input.size(-1) != self.input_size:
...@@ -68,5 +68,5 @@ class NeuralFilter1P(NeuralFilterCell): ...@@ -68,5 +68,5 @@ class NeuralFilter1P(NeuralFilterCell):
def step(self, input, hidden): def step(self, input, hidden):
in_gate = F.linear(input, self.weight_in, self.bias_in) in_gate = F.linear(input, self.weight_in, self.bias_in)
next = super(NeuralFilter1P, self).step(in_gate, hidden) next = super(NeuralFilter1L, self).step(in_gate, hidden)
return next return next
...@@ -25,7 +25,7 @@ along with neural_filters. If not, see <http://www.gnu.org/licenses/>. ...@@ -25,7 +25,7 @@ along with neural_filters. If not, see <http://www.gnu.org/licenses/>.
""" """
from . import NeuralFilterCell from . import NeuralFilter
import torch import torch
import numpy as np import numpy as np
...@@ -42,7 +42,7 @@ class NeuralFilter2CD (torch.nn.Module): ...@@ -42,7 +42,7 @@ class NeuralFilter2CD (torch.nn.Module):
self.hidden_size = hidden_size self.hidden_size = hidden_size
self.cell = NeuralFilterCell(self.hidden_size) self.cell = NeuralFilter(self.hidden_size)
def reset_parameters(self, init=None): def reset_parameters(self, init=None):
self.cell.reset_parameters(init) self.cell.reset_parameters(init)
......
...@@ -25,7 +25,7 @@ along with neural_filters. If not, see <http://www.gnu.org/licenses/>. ...@@ -25,7 +25,7 @@ along with neural_filters. If not, see <http://www.gnu.org/licenses/>.
""" """
from . import NeuralFilterCell from . import NeuralFilter
import torch import torch
import numpy as np import numpy as np
...@@ -42,8 +42,8 @@ class NeuralFilter2R (torch.nn.Module): ...@@ -42,8 +42,8 @@ class NeuralFilter2R (torch.nn.Module):
self.hidden_size = hidden_size self.hidden_size = hidden_size
self.first_cell = NeuralFilterCell(self.hidden_size) self.first_cell = NeuralFilter(self.hidden_size)
self.second_cell = NeuralFilterCell(self.hidden_size) self.second_cell = NeuralFilter(self.hidden_size)
self.reset_parameters((-0.5, 0.5)) self.reset_parameters((-0.5, 0.5))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment