Hello,
I've started to learn about neural networks and the first examples
I've seen are the implementation of an OR logical gate, aswell as the
AND gate. I've implemented it as a perceptron with no hidden layers,
and I've done it this way because so far is the only way I've learned.
The R file with the implementation of the OR gate is:
ppton_or.R
----------------------------------------------------------------------
ppton_or <- function() {
x = array(c(1,1,1,1,0,0,1,1,0,1,0,1), dim=c(4,3))
y = c(0,1,1,1)
w = c(0,0,0)
b = 1
n = 1
k = 0
while(all(as.integer((x[,] %*% w) >= 0) == y) == FALSE) {
z = as.integer((x[n,] %*% w) >= 0)
if(z != y[n]) {
w = w+b*(y[n]-z)*x[n,];
}
n = n%%4+1
k = k+1
}
print(k)
print(w)
}
----------------------------------------------------------------------
I've would like to know if it is possible to implement this pretty
basic neural network with the nnet package. I've tried using the
"skip=TRUE" switch with "size=0" and filling x and y with
the training
data but it is not working. Neither do I know how to make it use a
heaviside function as the threshold function. If someone could give me
some hint I'll be pretty grateful.
Thanks,
Eduardo Grajeda.