Description Usage Arguments Value Examples
Fit the neural network
1 2 3 | fit_neural_network(train_X, train_y, test_X, test_y, n_hidden_layers = 1,
hidden_layer_sizes = c(20), n_iterations = 100, step_size = 0.01,
lambda = 0.001, n_cores = 8)
|
train_X |
Matrix of training data (data points in rows, features in columns) |
train_y |
Vector of labels for training data (these have to be integers from 0 to n_classes - 1) |
test_X |
Matrix of test data |
test_y |
Vector of labels for test data |
n_hidden_layers |
Number of hidden layers in the neural network |
hidden_layer_sizes |
Vector containing the number of neurons in each hidden layer |
n_iterations |
The number of iterations for fitting the neural network |
step_size |
The step size for updating parameters at each iteration |
lambda |
The regularisation parameter |
n_cores |
The number of parallel cores |
List containing the following elements: train_acc
, test_acc
, loss_over_time
,
prob_train
, prob_test
, pred_train
, pred_test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | data(toy_data)
plot(toy_train$X, col=toy_train$y+1, pch=16)
res = fit_neural_network(toy_train$X, toy_train$y, toy_test$X, toy_test$y, n_iterations = 1000, step_size = 0.001)
plot(res)
res
# Confusion matrix for test data
table(res$pred_test, toy_test$y)
## Not run:
data(mnist)
# Pick only first 1000 data points (for speed)
res = fit_neural_network(train$x[1:1000, ], train$y[1:1000], test$x[1:500, ], test$y[1:500], n_iterations = 1000, step_size = 0.0001)
plot(res)
res
res = CV_neural_network(train$x[1:500, ], train$y[1:500], test$x[1:250, ], test$y[1:250], n_iterations = 100, step_size = 0.0001)
table(res$pred_test, test$y[1:250])
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.