```r
library(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_neuralnet1 <- neuralnet(Y~.,data = LXyTr_data,hidden = 5,linear.output=FALSE)
pred_neuralnet1 <- predict(fit_neuralnet1,LXyTe_data)
err_neuralnet1 <- mean(pred_neuralnet1!=LXyTe_data[,1])
err_neuralnet1
```