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))
示例#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
示例#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))
示例#4
0
 def forward(self, inputs, device):
     x, = inputs
     return functions.fliplr(x),
示例#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))
 def f(x):
     y = functions.fliplr(x)
     return y * y
示例#8
0
 def forward(self, inputs, device):
     x, = inputs
     return functions.fliplr(x),