Пример #1
0
    def applyFilter(self,inputSig):
        if np.size(inputSig) == 1: 
            u = inputSig # Handle scalar case
            myXnn = self.Xnn # get current state
            self.Xnn = np.add(np.matmul(self.A,myXnn), self.B*u) # State updated
            ytemp = np.add(np.matmul(self.C,myXnn), self.D*u)
            filtSig = np.asscalar(ytemp)
        else: 
            filtSig = [0]*len(inputSig) # list of zeros
            for i in range(len(inputSig)):    
                u = inputSig[i]
                myXnn = self.Xnn # get current state
                self.Xnn = np.add(np.matmul(self.A,myXnn), self.B*u) # State updated
                ytemp = np.add(np.matmul(self.C,myXnn), self.D*u)
#                self.Xnn = np.add(matmult(self.A, myXnn), self.B*u)
#                ytemp = np.add(matmult(self.C, myXnn), self.D*u)
                filtSig[i] = np.asscalar(ytemp)
        return filtSig
Пример #2
0
    def forward(self, ngrami):

        x = self.C[ngrami[0, :], :][0]
        x = x.reshape((x.shape[0] * x.shape[1], 1))

        o = np.dot(self.H, x) + self.D
        a = self.sigmoid(o)
        e = np.dot(self.U, a) + self.B
        z = np.dot(self.W, x)
        y = np.add(e, z)

        return y, a, x
    def forward(self, ngrami):
        aux = self.C[ngrami[0, :], :][0]
        aux = aux.reshape((aux.shape[0] * aux.shape[1], 1))

        x = shared(np.asmatrix(aux, 'float32'))

        o = self.linear(self.H, x, self.D)
        a = self.sigmoid(o)
        e = self.linear(self.U, a, self.B)
        z = self.dot(self.W, x)
        y = np.add(e, z)

        return y, a, x