Ejemplo n.º 1
0
def observe_until_click(c):
    """
    Generates a vector of observed documents (=1) and unobserved documents (=0)
    under the assumption that the user observed all documents up to and
    including the last clicked one.

    :param c: The click vectors
    :type c: chainer.Variable

    :return: The observation vectors
    :rtype: chainer.Variable
    """
    return F.fliplr(F.clip(F.cumsum(F.fliplr(c), axis=1), 0.0, 1.0))
Ejemplo n.º 2
0
def chainer_fft_spectrogram(xr, xi, forward=True):
    T, O = xr.shape
    if (forward):  # STFT
        yr, yi = F.fft((xr, xi))
        yr = F.transpose(yr[:, :int(O / 2) + 1])
        yi = F.transpose(yi[:, :int(O / 2) + 1])
    else:  # iSTFT
        xr_cnj = F.fliplr(xr[:, 1:O - 1])
        xi_cnj = -F.fliplr(xi[:, 1:O - 1])
        xr = F.concat((xr, xr_cnj), axis=1)
        xi = F.concat((xi, xi_cnj), axis=1)
        yr, yi = F.ifft((xr, xi))
        yr = F.transpose(yr)
        yi = F.transpose(yi)
    return yr, yi
Ejemplo n.º 3
0
    def check_forward(self, x_data):
        x = chainer.Variable(x_data)
        y = functions.fliplr(x)

        testing.assert_allclose(y.data, numpy.fliplr(self.x))
Ejemplo n.º 4
0
 def forward(self, inputs, device):
     x, = inputs
     return functions.fliplr(x),
Ejemplo n.º 5
0
 def f(x):
     y = functions.fliplr(x)
     return y * y
    def check_forward(self, x_data):
        x = chainer.Variable(x_data)
        y = functions.fliplr(x)

        testing.assert_allclose(y.data, numpy.fliplr(self.x))
Ejemplo n.º 7
0
 def f(x):
     y = functions.fliplr(x)
     return y * y
Ejemplo n.º 8
0
 def forward(self, inputs, device):
     x, = inputs
     return functions.fliplr(x),