예제 #1
0
def transform(n_images,
              n_features,
              n_components=0,
              disable_pbar=False,
              linear=False,
              config_file=""):
    opu = OPU(disable_pbar=disable_pbar,
              open_at_init=False,
              config_file=config_file)
    if n_components != 0:
        opu.n_components = n_components
    ins = np.ones((n_images, n_features), dtype=np.uint8)

    with opu:
        print(opu.version())
        begin = time.time()
        opu.fit1d(ins)
        if linear:
            opu.linear_transform(ins)
        else:
            opu.transform(ins)
        elapsed = time.time() - begin
        print(
            f"{n_images} transforms in {elapsed:.2f} s ({n_images / elapsed:.2f} Hz)"
        )
예제 #2
0
def transform(n_images, n_features, n_components=0, disable_pbar=False):
    opu = OPU(disable_pbar=disable_pbar, open_at_init=False)
    if n_components != 0:
       opu.n_components = n_components
    ins = np.ones((n_images, n_features), dtype=np.uint8)

    with opu:
        print(opu.version())
        begin = time.time()
        opu.fit_transform1d(ins)
        elapsed = time.time() - begin
        print("{:d} transforms in {:.2f} s ({:.2f} Hz)".format(n_images,
                                                               elapsed, n_images / elapsed))