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