예제 #1
0
import gnumpy as gp
import LNFuncs as lnf
import LNLayer as lnl
import LNNet as lnn
from time import clock as clock


if __name__ == '__main__':
    # Load usps data
    X = np.load('usps_X_numpy.npy')
    Y = np.load('usps_Y_numpy.npy')
    X = X - np.reshape(np.mean(X,axis=1), (X.shape[0], 1))
    X = X / np.reshape(np.max(np.abs(X),axis=1), (X.shape[0], 1))
    # Split into random training/test portions (note: lnf.trte_split() returns
    # gp.garrays, i.e. arrays on the GPU)
    [Xtr, Ytr, Xte, Yte] = lnf.trte_split(X, Y, 0.8)
    # Configure network layer sizes
    obs_dim = X.shape[1]
    out_dim = Y.shape[1]
    hidden_size = 200
    layer_sizes = [obs_dim, hidden_size, hidden_size, out_dim]
    # Set some training options
    opts = lnf.check_opts()
    opts['rounds'] = 15000
    opts['batch_size'] = 100
    opts['start_rate'] = 0.1
    opts['momentum'] = 0.9
    opts['decay_rate'] = 0.1**(1.0 / opts['rounds'])
    opts['dev_reps'] = 2
    opts['do_validate'] = 1
    opts['Xv'] = Xte