Exemplo n.º 1
0
# when initializing gradient descent : epochs = 1e6, momentum = 0.999
f, g, _, _ = bib_data.get_tomo_JET(fname, faulty=False, flatten=True)

g = np.transpose(g) * 1e3
f = np.transpose(f) * 1e3

print 'g:', g.shape, g.dtype
print 'f:', f.shape, f.dtype

# ------------------------------------------------------------------------
# Divide into training and validation set
# (no test set needed since it won't overfit)
# if one wants the validation set can also be disregarded by setting ratio=[1.,0.]

i_train, i_valid, _ = bib_utils.divide_data(g.shape[1],
                                            ratio=[.9, .1],
                                            test_set=False,
                                            random=False)

g_valid = g[:, i_valid]
f_valid = f[:, i_valid]
g = g[:, i_train]
f = f[:, i_train]

print 'g_train:', g.shape, g.dtype
print 'f_train:', f.shape, f.dtype
print 'g_valid:', g_valid.shape, g_valid.dtype
print 'f_valid:', f_valid.shape, f_valid.dtype

np.savez(save_path + 'i_divided', i_train=i_train, i_valid=i_valid)

# ------------------------------------------------------------------------
Exemplo n.º 2
0
f, g, _, _ = bib_data.get_tomo_JET(fname,
                                   faulty=True,
                                   flatten=False,
                                   clip_tomo=True)

# need to reshape image to match NN dimensions
g = bib_utils.resize_NN_image(g, training=True)

print 'g:', g.shape, g.dtype
print 'f:', f.shape, f.dtype

# ------------------------------------------------------------------------
# Divide into training, validation and test set

i_train, i_valid, i_test = bib_utils.divide_data(g.shape[0],
                                                 ratio=[.8, .1, .1],
                                                 test_set=True,
                                                 random=False)

f_valid = f[i_valid]
g_valid = g[i_valid]
f_train = f[i_train]
g_train = g[i_train]

print 'f_train:', f_train.shape
print 'g_train:', g_train.shape
print 'f_valid:', f_valid.shape
print 'g_valid:', g_valid.shape

np.savez(save_path + 'i_divided',
         i_train=i_train,
         i_valid=i_valid,