最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wolfram mathematica - What should be the data format for a neural network with 2 inputs and a scalar output - Stack Overflow

programmeradmin1浏览0评论

I have a very simple network model: two named input ports, one summing layer, one linear layer and a scalar output. Despite many attempts, I cannot select a suitable data format that would be accepted by NetTrain. I get the message:

Data provided to port “Input1” should be a non-empty list of length-1 vectors, but was a length-2 vector of real numbers ”

Code attached

Module[{mData, mNetwork},
mData = Dataset[{Association["Input1" -> 1, "Input2" -> 2, 
 "Output" -> 3], 
Association["Input1" -> 2, "Input2" -> 3, "Output" -> 4]}];
mNetwork = NetGraph[{
LinearLayer[1, "Input" -> 1, "Weights" -> {{1}}, "Biases" -> None],
ThreadingLayer[Plus, InputPorts -> 2]
},
{{NetPort["Input1"], NetPort["Input2"]} -> 2 -> 1}
];
mNetwork = NetInitialize[mNetwork];
NetTrain[mNetwork, mData, "TrainedNet",`MaxTrainingRounds -> 3, LossFunction -> MeanSquaredLossLayer[]];`
]

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论