예제 #1
0
파일: gru.py 프로젝트: vishalgolcha/chainer
    def forward(self, x):
        z = self.W_z(x)
        h_bar = self.W(x)
        if self.h is not None:
            r = sigmoid.sigmoid(self.W_r(x) + self.U_r(self.h))
            z += self.U_z(self.h)
            h_bar += self.U(r * self.h)
        z = sigmoid.sigmoid(z)
        h_bar = tanh.tanh(h_bar)

        if self.h is not None:
            h_new = linear_interpolate.linear_interpolate(z, h_bar, self.h)
        else:
            h_new = z * h_bar
        self.h = h_new
        return self.h
예제 #2
0
파일: gru.py 프로젝트: Fhrozen/chainer
    def __call__(self, x):
        z = self.W_z(x)
        h_bar = self.W(x)
        if self.h is not None:
            r = sigmoid.sigmoid(self.W_r(x) + self.U_r(self.h))
            z += self.U_z(self.h)
            h_bar += self.U(r * self.h)
        z = sigmoid.sigmoid(z)
        h_bar = tanh.tanh(h_bar)

        if self.h is not None:
            h_new = linear_interpolate.linear_interpolate(z, h_bar, self.h)
        else:
            h_new = z * h_bar
        self.h = h_new
        return self.h
예제 #3
0
    def __call__(self, x):
        z = self.W_z(x)
        h_bar = self.W(x)
        if self.h is not None:
            r = hard_sigmoid.hard_sigmoid(self.W_r(x) + self.U_r(self.h))
            z += self.U_z(self.h)
            h_bar += self.U(r * self.h)  # this may differs by version
        z = hard_sigmoid.hard_sigmoid(z)
        h_bar = tanh.tanh(h_bar)

        if self.h is not None:
            h_new = linear_interpolate.linear_interpolate(z, self.h, h_bar)  #(z, h_bar, self.h)
        else:
            h_new = ( 1- z) * h_bar
        self.h = h_new
        
        return self.h
예제 #4
0
    def __call__(self, x):
        z = self.W_z(x)
        h_bar = self.W(x)
        if self.h is not None:
            z += self.U_z(self.h)
            if self.use_reset_gate:
                r = sigmoid.sigmoid(self.W_r(x) + self.U_r(self.h))
                h_bar += self.U(r * self.h)
            else:
                h_bar += self.U(self.h)
        z = sigmoid.sigmoid(z)
        h_bar = self.activation(h_bar)

        if self.h is not None:
            h_new = linear_interpolate.linear_interpolate(z, h_bar, self.h)
        else:
            h_new = z * h_bar
        self.h = h_new
        return self.h
예제 #5
0
파일: links.py 프로젝트: SilvanQuax/PercDec
    def __call__(self, x):
        z = self.W_z(x)
        h_bar = self.W(x)
        if self.h is not None:
            r = sigmoid.sigmoid(self.W_r(x) + self.U_r(self.h))
            z += self.U_z(self.h)
            h_bar += self.U(r * self.h)
        else:
            r = sigmoid.sigmoid(self.W_r(x) + self.U_r(self.H0(z)))
            z += self.U_z(self.H0(z))
            h_bar += self.U(r * self.H0(z))

        z = sigmoid.sigmoid(z)
        h_bar = clipped_relu.clipped_relu(h_bar, z=1.0)

        if self.h is not None:
            h_new = linear_interpolate.linear_interpolate(z, h_bar, self.h)
        else:
            h_new = z * h_bar

        self.h = h_new

        return self.h
예제 #6
0
파일: gru.py 프로젝트: Fhrozen/chainer
 def __call__(self, h, x):
     r = sigmoid.sigmoid(self.W_r(x) + self.U_r(h))
     z = sigmoid.sigmoid(self.W_z(x) + self.U_z(h))
     h_bar = tanh.tanh(self.W(x) + self.U(r * h))
     h_new = linear_interpolate.linear_interpolate(z, h_bar, h)
     return h_new
예제 #7
0
파일: gru.py 프로젝트: vishalgolcha/chainer
 def forward(self, h, x):
     r = sigmoid.sigmoid(self.W_r(x) + self.U_r(h))
     z = sigmoid.sigmoid(self.W_z(x) + self.U_z(h))
     h_bar = tanh.tanh(self.W(x) + self.U(r * h))
     h_new = linear_interpolate.linear_interpolate(z, h_bar, h)
     return h_new
예제 #8
0
 def _call_mgu(self, h, x):
     f = sigmoid.sigmoid(self.W_f(concat.concat([h, x])))
     h_bar = tanh.tanh(self.W_h(concat.concat([f * h, x])))
     h_new = linear_interpolate.linear_interpolate(f, h_bar, h)
     return h_new
예제 #9
0
파일: mgu.py 프로젝트: asi1024/chainer
 def _call_mgu(self, h, x):
     f = sigmoid.sigmoid(self.W_f(concat.concat([h, x])))
     h_bar = tanh.tanh(self.W_h(concat.concat([f * h, x])))
     h_new = linear_interpolate.linear_interpolate(f, h_bar, h)
     return h_new