View source: R/Personal_Functions.R
Binary_Network | R Documentation |
Used as a function of Feed_Reduction, Binary_Networt uses a 3 layer neural network with an adam optimizer, leaky RELU for the first two activation functions, followed by a softmax on the last layer. The loss function is binary_crossentropy. This is a keras wrapper, and uses tensorflow in the backend.
Binary_Network(X, Y, X_test, val_split, nodes, epochs, batch_size, verbose = 0)
X |
Training data. |
Y |
Training Labels. These must be binary. |
X_test |
The test Data |
val_split |
The validation split for keras. |
nodes |
The number of nodes in the hidden layers. |
epochs |
The number of epochs for the network |
batch_size |
The batch size for the network |
verbose |
Weither or not you want details about the run as its happening. 0 = silent, 1 = progress bar, 2 = one line per epoch. |
This function is a subset for the larger function Feed_Network. The output is the list containing the training and testing data converted into an approximation of probability space for that binary decision.
Train |
The training data in approximate probability space |
Test |
The testing data in 'double' approximate probability space |
Travis Barton
Check out http://wbbpredictions.com/wp-content/uploads/2018/12/Redditbot_Paper.pdf and Keras for details
Feed_Network
## Not run: if(8 * .Machine$sizeof.pointer == 64){ #Feed Network Testing library(keras) library(dplyr) install_keras() dat <- keras::dataset_mnist() X_train = array_reshape(dat$train$x/255, c(nrow(dat$train$x/255), 784)) y_train = to_categorical(dat$train$y, 10) X_test = array_reshape(dat$test$x/255, c(nrow(dat$test$x/255), 784)) y_test =to_categorical(dat$test$y, 10) index_train = which(dat$train$y == 6 | dat$train$y == 5) index_train = sample(index_train, length(index_train)) index_test = which(dat$test$y == 6 | dat$test$y == 5) index_test = sample(index_test, length(index_test)) temp = Binary_Network(X_train[index_train,], y_train[index_train,c(7, 6)], X_test[index_test,], .3, 350, 30, 50) } ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.