keras_fit | R Documentation |
Learn the weight and bias values for am model given training data. Model must be compiled first. The model is modified in place.
keras_fit(model, x, y, batch_size = 32, epochs = 10, verbose = 1, callbacks = NULL, validation_split = 0, validation_data = NULL, shuffle = TRUE, class_weight = NULL, sample_weight = NULL, initial_epoch = 0)
model |
a keras model object, for example created with |
x |
numeric matrix of input data |
y |
a numeric matrix or numeric vector containing labels. |
batch_size |
integer. Number of samples per gradient update. |
epochs |
integer, the number of epochs to train the model. |
verbose |
0 for no logging to stdout, 1 for progress bar logging, 2 for one log line per epoch. |
callbacks |
list of callbacks to apply during training.
See |
validation_split |
numeric ( |
validation_data |
|
shuffle |
boolean or string (for |
class_weight |
dictionary mapping classes to a weight value, used for scaling the loss function (during training only). |
sample_weight |
numeric array of weights for the training samples |
initial_epoch |
epoch at which to start training |
Taylor B. Arnold, taylor.arnold@acm.org
Chollet, Francois. 2015. Keras: Deep Learning library for Theano and TensorFlow.
keras_compile()
Other model functions: LoadSave
,
Predict
, Sequential
,
keras_compile
if(keras_available()) { X_train <- matrix(rnorm(100 * 10), nrow = 100) Y_train <- to_categorical(matrix(sample(0:2, 100, TRUE), ncol = 1), 3) mod <- Sequential() mod$add(Dense(units = 50, input_shape = dim(X_train)[2])) mod$add( Dropout(rate = 0.5)) mod$add(Activation("relu")) mod$add(Dense(units = 3)) mod$add(ActivityRegularization(l1 = 1)) mod$add(Activation("softmax")) keras_compile(mod, loss = 'categorical_crossentropy', optimizer = RMSprop()) keras_fit(mod, X_train, Y_train, batch_size = 32, epochs = 5, verbose = 0, validation_split = 0.2) # You can also add layers directly as arguments to Sequential() mod <- Sequential( Dense(units = 50, input_shape = ncol(X_train)), Dropout(rate = 0.5), Activation("relu"), Dense(units = 3), ActivityRegularization(l1 = 1), Activation("softmax") ) keras_compile(mod, loss = 'categorical_crossentropy', optimizer = RMSprop()) keras_fit(mod, X_train, Y_train, batch_size = 32, epochs = 5, verbose = 0, validation_split = 0.2) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.