2
$\begingroup$

Consider this sequence:

net = NetInitialize[
  NetChain[{LinearLayer[100], LogisticSigmoid, LinearLayer[100], 
    LogisticSigmoid, LinearLayer[100], LogisticSigmoid, 
    LinearLayer[100], LogisticSigmoid, LinearLayer[1] }, 
   "Input" -> {2, 11}]]

net = NetTrain[net, foo]

Tells me that the first element to NetTrain[] should be a fully specified net. But what is it about the net that is underspecified?

$\endgroup$
6
  • $\begingroup$ Probably fails for some other reason (wrong data input format for foo?). Don't assign the output of NetTrain to net again, if it fails it would reassign it to something like $Failed and wouldn't work anymore. $\endgroup$
    – swish
    May 13, 2017 at 22:40
  • $\begingroup$ Post foo please $\endgroup$
    – M.R.
    May 14, 2017 at 0:33
  • $\begingroup$ @M.R. sure thing: dropbox.com/s/o88f3zpph5k4tze/foo?dl=0 $\endgroup$
    – Igor Rivin
    May 14, 2017 at 0:52
  • $\begingroup$ @swish Actually, assigning the output to newnet does not give the error any more, and trains fine! Weird. $\endgroup$
    – Igor Rivin
    May 14, 2017 at 0:54
  • 1
    $\begingroup$ As @swish suggests, this problem is due to something like NetTrain[$Failed,foo]. For example, run this net = NetTrain[net, {RandomReal[{0, 1}, {2, 11}] -> 1}] and then net = NetTrain[net, {RandomReal[{0, 1}, {2, 11}] -> {1}}] you will get the exact same error message, although the second expression is correct. $\endgroup$ May 14, 2017 at 5:00

1 Answer 1

2
$\begingroup$

As swish hinted, the problem may due to an incorrect previous return. For example:

net = NetInitialize[
  NetChain[{LinearLayer[100], LogisticSigmoid, LinearLayer[100], 
    LogisticSigmoid, LinearLayer[100], LogisticSigmoid, 
    LinearLayer[100], LogisticSigmoid, LinearLayer[1]}, 
   "Input" -> {2, 11}]]

If we provide the incorrect training data, NetTrain fails with an error message

net = NetTrain[net, {RandomReal[{0, 1}, {2, 11}] -> 1}]
(* $Failed *)

NetTrain::invindim: Data provided to port "Output" should be a list of length-1 vectors.

Now if you run the training again with the correct data, you get the same error message in your question

net = NetTrain[net, {RandomReal[{0, 1}, {2, 11}] -> {1}}]
(* $Failed *)

NetTrain::invnet: First argument to NetTrain should be a fully specified net.

This is because, in the second run, the net has a value of $Failed, which is not a neural network.

$\endgroup$

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.