# file b_nnet_xor.R library(nnet) inputData=matrix(c( 0,0, 0,1, 1,0, 1,1), nrow=4,byrow=TRUE) outputData=matrix(c( 0, 1, 1, 0), nrow=4,byrow=TRUE) myXor=nnet(x=inputData, y=outputData, size=2) #,abstol=0.0001) # sometimes, we have bad solutions, try size=3 # or use: #abstol - Stop if the fit criterion falls below abstol, # indicating an essentially perfect fit. #reltol - Stop if the optimizer is unable to reduce the fit # criterion by a factor of at least 1 - reltol. print(summary(myXor)) #verification print(predict(myXor,inputData)) #on the fly predict(myXor,c(0,1))