dimanche 19 février 2023

nnet() different results in different operating systems (Windows vs Linux)

I am working with R scripts specifically for ANN models using the nnet() package. I run my scripts on my local computer (Windows) and my colleague runs the same R scripts on his computer (Docker -> Linux). We get similar but different results for the ANN models. There are large differences in the neuron weights, and slight differences in fitted values and predictions.

We are setting the same seed just before the nnet() function so we are on the same randomization set. Additionally, I have set the initialization weights ("Wts") to be the same value (1) for all coefficients, biases etc for the model. I have also tested the randomization of both systems by setting the seed and doing a random sample(), which returns the same results.

I have also tested our model inputs (spectra) and everything is 1:1 unity.

We build a number of models including PLS, GPR and SVR (with grid search parameters) and we always get the same result. These models do not utilize randomization so the assumption is that the randomization within the ANN models is the cause for the difference.

We have also updated R to the most recent version (4.2.2) and updated all of our packages including nnet() and dependencies from the same repository.

I am at a loss on what the difference could be from, my last thought is the difference between operating systems (me = Windows, he = Linux). Could there be another difference that could affect the nnet() function such as rounding (as the model input variables are in low magnitude decimals) or ordering differences between the operating systems?

The expectation is to have complete unity across ANN models (weights, fitted values and predictions).

Sorry for no reproducible code, the models work on high dimensional data (spectra > 1000 variables, n > 1000). I can share our nnet() function code:

  cv_wts <- rep(1,cv_wts_n)
  
  set.seed(seed)
  cal <- nnet(TV ~ NIR, data = training_dat, size = n, decay = d, Wts = cv_wts,
              linout=TRUE, maxit = 1000000, MaxNWts = 1000000, trace = FALSE)



Aucun commentaire:

Enregistrer un commentaire