Protected
constructorProtected
Readonly
batchProtected
Readonly
consoleProtected
Readonly
dataProtected
Readonly
epochProtected
modelProtected
Readonly
nameProtected
Readonly
nameProtected
Readonly
testingProtected
Readonly
trainingProtected
Readonly
useGets a sample of test data and returns the model output, with some basic operations to reshape the output as 1d tensor.
A list of two elements that are 1d tensors corresponding to a list [b1, b2, ...]. These two list are 0-1 lists for each batch element to be a bot trajectory (1 means bot).
The batch size for the sample.
Add the last layer that decides the class of the input
for the classifier and compile the model.
The last layer is dense with 'varianceScaling' kernel initializer,
and we look at accuracy metric.
When there is only one class in DataTraining ([0] for human,
[1] for bot), we use a binaryCrossentropy loss function and the
activation of the dense layer is the sigmoid function. If we have
two classes ([1,0] for human, [0,1] for bot), it is the categoricalCrossentropy
loss function and softmax activation.
The same model as input that has been compiled.
The model returned by initModel.
Get prediction and labels and return the accuracy per class.
The model prediction reshaped as 1D tensor of 0 (human) or 1 (bot).
The true labels, 1d tensor of 0 or 1.
Get prediction and labels and return the confusion matrix.
The model prediction reshaped as 1D tensor of 0 (human) or 1 (bot).
The true labels, 1d tensor of 0 or 1.
Create a new sequential model with tf.sequential(), add
all hidden layers and returns the result. Notice that the input
shape will always be [this.data.data.getXSize(), this.data.data.getYSize()]
or [null, this.data.data.getYSize()]
if we want to allow different
time steps for recurrent models after training (however, for training, a
recurrent model such as LSTM must have a fixed input shape for gradient
descent).
The new sequential model.
Run the entire training process, from data loading to model training, then model testing with accuracy and confusion matrix. If field nameToLoad is specified, training is ignored because we directly call loadExistingModel. If field nameToSave is specified, it save the model by calling tf.LayersModel.save.
Get the model prediction batch and its corresponding labels as 1D tensors and show with tfjs-vis or in console (according to useTfjsVis and consoleInfo) the accuracy of each class and the confusion matrix.
The model prediction reshaped as 1D tensor of 0 (human) or 1 (bot).
The true labels, 1d tensor of 0 or 1.
Default to "validation", used in the container name of tfjs-vis.
Train the model with tf.LayersModel.fit. We first get a fragment of training and testing data according to trainingRatio and testingRatio, default set to 1 and 0.9 respectively. Then we fit the model with the corresponding batchSize and epochs.
Generated using TypeDoc
Abstract class used to create a new TensorFlow.js model and train it from a dataset DataTraining. Call
The constructor takes an object with parameters :
Extend this class to create your own model logic, all you have to do is implement the method initModel that creates and returns a new Sequential model, not compiled. The method finalizeModel adds the last dense layer to the number of classes and compiles the model, you can also override this one to modify the behavior of the last layers or how to compile the model.