O'Reilly logo

R Deep Learning Projects by Pablo Maldonado, Yuxi Liu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Perceptron as an R6 class

The perceptron is the simplest neural network. It consists of an input and an output (no hidden layers), and the activation function is just the Heaviside function (step function at the origin), when the bias term is included.

This is the skeleton of the class:

library(R6)Perceptron <- R6Class("Perceptron",  public = list(     threshold = NULL,     dim = NULL,     n_iter = NULL,     learning_rate = NULL,     w = NULL, initialize = function(threshold = 0, learning_rate = 0.25, n_iter=100, dim=2){     self$n_iter <- n_iter     self$threshold <- threshold     self$learning_rate <- learning_rate } , forward = function(x){     } , backward = function(t,y,x){     } } , train = function(X,t){     } } } } , predict = function(X){     X <- cbind(-1,X) #add bias preds <- ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required