Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with compute/predict.nn (CRAN v1.44.2) #24

Open
leraman opened this issue Mar 7, 2019 · 5 comments
Open

Problems with compute/predict.nn (CRAN v1.44.2) #24

leraman opened this issue Mar 7, 2019 · 5 comments

Comments

@leraman
Copy link

leraman commented Mar 7, 2019

Hi,

I recently updated neuralnet to v1.44.2 from v1.33. The newest version appears to contain a broken compute() function, which worked fine in v1.33. It throws following error:
Error in cbind(1, pred) %*% weights[[i]] : non-conformable arguments Calls: predict -> compute -> predict.nn -> <Anonymous> In addition: Warning message: In cbind(1, pred) : number of rows of result is not a multiple of vector length (arg 1) Execution halted

I've read that compute() was decrypted, yet R seems to be unable to find the 'new' predict(), neuralnet::predict() or predict.nn() functions.

@leraman
Copy link
Author

leraman commented Mar 7, 2019

(important?) note: the model I'm using was created using version v1.33. Could that be the problem?

Edit: I trained a new model using v1.44.2, problem is still there.

@mnwright
Copy link
Member

mnwright commented Mar 7, 2019

Hm... On my machine predict() and compute() run fine with models from both version. Could you try to re-install the package and start in a fresh R session? You should be able to run the following code:

library(neuralnet)
nn <- neuralnet(Species == "setosa" ~ Petal.Length + Petal.Width, iris, linear.output = FALSE)
predict(nn, iris)

and get a 150x1 numeric back.

@leraman
Copy link
Author

leraman commented Mar 8, 2019

Hi @mnwright

I solved the issue--my bad after all. My script saves a 'minimal' (using as less space as possible) trained model which can be used for prediction in a later stage (using .Rdata format). Version 1.33 only required the 'linear output' and 'weights' elements from the model object, but it turns out v1.44.2 requires the 'model.list' element as well. I might have missed this, but I don't think there is a nice solution/function to save such models?

Thanks !

@mnwright
Copy link
Member

mnwright commented Mar 8, 2019

We need length(object$model.list$variables) to subset the new data if necessary (if not all columns were used for training). However, I've just changed that to skip the subset if length(object$model.list$variables) is not there. Are your reduced models working now?

@leraman
Copy link
Author

leraman commented Mar 8, 2019

I've made sure the 'model.list' is included in the output and retrained my model, to avoid compatibility issues with CRAN versions when used by others. Thanks for your solution anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants