```r
library(neuralnet) #install.packages("neuralnet")
LXyTr_data <- data.frame(Y=factor(LXyTr[,1]),x=LXyTr[,-1])
LXyTe_data <- data.frame(Y=factor(LXyTe[,1]),x=LXyTe[,-1])
colnames(LXyTr_data) <- c("Y",paste0("x",1:D^2))
colnames(LXyTe_data) <- c("Y",paste0("x",1:D^2))

fit_neuralnet2 <- neuralnet(Y~.,data = LXyTr_data,hidden = c(2,2),linear.output=FALSE)
pred_neuralnet2 <- predict(fit_neuralnet2,LXyTe_data)
err_neuralnet2 <- mean(pred_neuralnet2!=LXyTe_data[,1])
err_neuralnet2
```