Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######################################################
- x, y = pickle.load(open('train.pkl', 'rb'))
- x_hist = np.zeros((x.shape[0], 36))
- for i, row in enumerate(x):
- hist, _ = np.histogram(row, bins=36)
- x_hist[i] = hist
- ######################################################
- x_train = x_hist[0:10000]
- y_train = y[0:10000]
- x_val = x_hist[10000:12500]
- y_val = y[10000:12500]
- ######################################################
- mlp = MLP(n_features=x_train.shape[1], n_hidden=50, n_output=10,
- eta=0.001, decrease_const=0.000005, l1=0.1, l2=0.1, alpha=0.001, batch_size=50)
- costs = mlp.fit(x_train, y_train, epochs=1000, show_progress=True)
- # validation
- predictions = mlp.predict(x_val)
- accuracy = np.sum(y_val == predictions, axis=0) / x_val.shape[0]
- print("Validation accuracy: %.2f" % accuracy)
- ######################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement