def test():
    with UnitTimer(12):
        for _ in range(12):
            for i, j in group((x0, x1, x2)):
                # print(i.shape, j.shape)
                pass
Exemplo n.º 2
0
from odin.search import (diagonal_beam_search, diagonal_bruteforce_search,
                         diagonal_greedy_search, diagonal_hillclimb_search)
from odin.utils import UnitTimer

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'

tf.random.set_seed(8)
np.random.seed(8)

shape = (8, 8)
mat = np.random.randint(0, 88, size=shape)
print(mat)

with UnitTimer():
    ids = diagonal_beam_search(mat)
print(ids)
print(mat[:, ids])
print(np.sum(np.diag(mat[:, ids])))

with UnitTimer():
    ids = diagonal_hillclimb_search(mat)
print(ids)
print(mat[:, ids])
print(np.sum(np.diag(mat[:, ids])))

with UnitTimer():
    ids = diagonal_greedy_search(mat)
print(ids)
print(mat[:, ids])
Exemplo n.º 3
0
X_valid, y_mRNA_valid, y_prot_valid, y_bin_valid, y_prob_valid = data[
    valid], y_mRNA[valid], y_prot[valid], y_bin[valid], y_prob[valid]
X_test, y_mRNA_test, y_prot_test, y_bin_test, y_prob_test = data[test], y_mRNA[
    test], y_prot[test], y_bin[test], y_prob[test]
print(ctext("Train:", 'cyan'), X_train.shape, y_mRNA_train.shape,
      y_prot_train.shape, y_bin_train.shape, y_prob_train.shape)
print(ctext("Valid:", 'cyan'), X_valid.shape, y_mRNA_valid.shape,
      y_prot_valid.shape, y_bin_valid.shape, y_prob_valid.shape)
print(ctext("Test:", 'cyan'), X_test.shape, y_mRNA_test.shape,
      y_prot_test.shape, y_bin_test.shape, y_prob_test.shape)
# ===========================================================================
# Evaluation
# ===========================================================================
random_state = get_rng().randint(0, 10e8)
# ====== create transformer ====== #
with UnitTimer(name="Fit PCA"):
    pca = PCA(n_components=NUM_COMPONENTS, random_state=random_state)
    pca.fit(X_train)

with UnitTimer(name="Fit PPCA"):
    ppca = PPCA(n_components=NUM_COMPONENTS,
                verbose=True,
                random_state=random_state)
    ppca.fit(X_train)

with UnitTimer(name="Fit S-PPCA"):
    sppca = SupervisedPPCA(n_components=NUM_COMPONENTS,
                           verbose=True,
                           extractor='supervised',
                           random_state=random_state)
    X_, y_ = [], []
Exemplo n.º 4
0
            T.sum(const2.T**3))


outputs, update = theano.scan(step_non,
                              sequences=theano.shared(
                                  np.arange(12 * 12 * 12 * 8 * 8).reshape(
                                      12 * 12 * 12, 8, 8)),
                              outputs_info=theano.shared(np.ones((8, 8))),
                              strict=False)
f_non = theano.function(inputs=[], outputs=outputs, allow_input_downcast=True)

time.sleep(0.5)

for i in range(3):
    print('Non-strict scan:')
    with UnitTimer(8):
        for i in range(8):
            f_non()

    print('Strict scan:')
    with UnitTimer(8):
        for i in range(8):
            f_strict()

# Non - strict scan:
# Time: 0.064988 (sec)
# Strict scan:
# Time: 0.058314 (sec)
# Non - strict scan:
# Time: 0.059891 (sec)
# Strict scan: