I am working on a package of functions that complement the NeuralNetworks` package that Wolfram provides. I am having a problem with the following code, which is essentially a wrapper for two commands that I run frequently:

runNetwork[data_,desc_,dlist_,{tlist_,vlist_}]:= Module[{fdfwd,m,r},
    fdfwd = InitializeRBFNet[
    {m,r} = NeuralFit[fdfwd,

When I declare this function within my notebook, it runs as expected; however if I place it in a package (for instance, MyNeuralNetworks`) then I get errors of the following type:

Set::shape: "Lists {SolarNeuralNetwork`Private`m\$2436,SolarNeuralNetwork`Private`r\$2436} and SolarNeuralNetwork`Private`NeuralFit[<<1>>] are not the same shape."

which suggests to me that the list fdfwd that is returned by the first function is not being passed correctly to the second function. I have tried adding a Needs["NeuralNetworks`"] line in both the Public and Private portions of the package as well as in the BeginPackage line following this question and answer. I'm new to package writing, so there may be something obvious I'm missing. It's possible that the answer I'm looking for is hidden somewhere in this discussion but I don't know how to implement those suggestions in my context.


1 Answer 1


Perhaps this question may be of use to future visitors. I had assumed that using




was sufficient to establish the $ContextPath for my package; however when I loaded the neural networks package into a notebook, I noticed:

{"NeuralNetworks`VQ`", "NeuralNetworks`UnsupervisedNet`", "NeuralNetworks`Perceptron`",
   "NeuralNetworks`NeuralFit`", "NeuralNetworks`Hopfield`",
   "NeuralNetworks`FeedForwardRBFNet`", "NeuralNetworks`DynamicNet`", 
    "NeuralNetworks`Common`", "NeuralNetworks`CommonCBV`", "NeuralNetworks`", ...}

I wrongfully thought that Needing NeuralNetworks` would automatically include the rest of the needed packages into my context. Explicitly including all of the neural network packages in my custom package did the trick:

BeginPackage["MyNeuralNetwork`",{"NeuralNetworks`VQ`", "NeuralNetworks`UnsupervisedNet`", 
   "NeuralNetworks`Perceptron`", "NeuralNetworks`NeuralFit`",
   "NeuralNetworks`Hopfield`", "NeuralNetworks`FeedForwardRBFNet`",
   "NeuralNetworks`DynamicNet`", "NeuralNetworks`Common`",
   "NeuralNetworks`CommonCBV`", "NeuralNetworks`"}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.