def main():
    args = parse_args()
    with open(args.config_file) as fp:
        config = yaml.safe_load(fp)
    input_timesteps = config['input_timesteps']
    output_timesteps = config['output_timesteps']
    batch_size = config['batch_size']
    data = load_wave(args.input_file)
    print('data.shape is:', data.shape)
    print('data.len is:', len(data))
    '\n    from nnabla.ext_utils import get_extension_context\n    cuda_device_id = 0\n    ctx = get_extension_context(\'cudnn\', device_id=cuda_device_id)\n    print("Context: {}".format(ctx))\n    nn.set_default_context(ctx)  # Set CUDA as a default context.\n    '
    block_size = (output_timesteps * batch_size)
    prepad = (input_timesteps - output_timesteps)
    postpad = (len(data) % block_size)
    print('postpad', (block_size - postpad))
    padded = np.concatenate((np.zeros(prepad, np.float32), data, np.zeros((block_size - postpad), np.float32)))
    x = sliding_window(padded, input_timesteps, output_timesteps)
    x = x[:, :, np.newaxis]
    y = np.zeros_like(x)
    batchlen = x.shape[0]
    print('x.length is:', batchlen)
    xx = nn.Variable((batch_size, input_timesteps, 1))
    nn.load_parameters('best_result.h5')
    print('xx.shape is:', xx.shape)
    yy = build_model(xx)
    print('yy.shape is:', yy.shape)
    print('x.shape in the loop is:', x[32:(32 + batch_size), :, :].shape)
    start1 = time()
    for step in range(0, batchlen, batch_size):
        xx.d = x[step:(step + batch_size), :, :]
        yy.forward()
        y[step:(step + batch_size), :, :] = yy.d
        proc_time = (time() - start1)
        print(proc_time)
        print(step)
    y = y[:, (- output_timesteps):, :].reshape((- 1))[:len(data)]
    save_wave(y, args.output_file)
    print('finished\n')
    proc_time = (time() - start1)
    print(proc_time)
def main():
    args = parse_args()
    with open(args.config_file) as fp:
        config = yaml.safe_load(fp)
    input_timesteps = config['input_timesteps']
    output_timesteps = config['output_timesteps']
    batch_size = config['batch_size']
    data = load_wave(args.input_file)
    print('data.shape is:', data.shape)
    print('data.len is:', len(data))
    '\n    from nnabla.ext_utils import get_extension_context\n    cuda_device_id = 0\n    ctx = get_extension_context(\'cudnn\', device_id=cuda_device_id)\n    print("Context: {}".format(ctx))\n    nn.set_default_context(ctx)  # Set CUDA as a default context.\n    '
    block_size = (output_timesteps * batch_size)
    prepad = (input_timesteps - output_timesteps)
    postpad = (len(data) % block_size)
    print('postpad', (block_size - postpad))
    padded = np.concatenate((np.zeros(prepad, np.float32), data, np.zeros((block_size - postpad), np.float32)))
    x = sliding_window(padded, input_timesteps, output_timesteps)
    x = x[:, :, np.newaxis]
    y = np.zeros_like(x)
    batchlen = x.shape[0]
    print('x.length is:', batchlen)
    xx = nn.Variable((batch_size, input_timesteps, 1))
    nn.load_parameters('best_result.h5')
    print('xx.shape is:', xx.shape)
    yy = build_model(xx)
    print('yy.shape is:', yy.shape)
    print('x.shape in the loop is:', x[32:(32 + batch_size), :, :].shape)
    start1 = time()
    for step in range(0, batchlen, batch_size):
        xx.d = x[step:(step + batch_size), :, :]
        yy.forward()
        y[step:(step + batch_size), :, :] = yy.d
        proc_time = (time() - start1)
        print(proc_time)
        print(step)
    y = y[:, (- output_timesteps):, :].reshape((- 1))[:len(data)]
    save_wave(y, args.output_file)
    print('finished\n')
    proc_time = (time() - start1)
    print(proc_time)