My current workaround is to have cds fetch pairs (X,TW) where TW=[T,W] is the concatenation of the actual targets T and the desired weights W. I can then decompose TW into T and W inside the lossFcn(). However, I am wondering if there is a more graceful way.
Passing additional minibatchable quantities to a trainnet() loss function
3 次查看(过去 30 天)
显示 更早的评论
I am calling trainnet() with the syntax,
netTrained = trainnet(cds,net,lossFcn,options)
where lossFcn=f(Y,T) is a handle to a custom loss function. Here the variable Y is the network prediction based on input X and T is the training target. Both Y and T are S1xS2xC images. During training, the usual operation of trainnet() is to fetch minibatched pairs (X,T) pointed to by the CombinedDataStore cds and to give the pairs (Y(X),T) to the lossFcn.
I would now like to modify the training to have a loss function of the form lossFcn=f(Y,T,W) where W is an additional minibatchable data set containing known, constant weights, and is of the same dimensions as Y and T. My question is if there is a way to combine 3 datastores instead of 2 datastores to make this happen. In other words, is it possible to have cds read in minibatched triplets (X,T,W) and to give (Y(X),T,W) to the loss function?
And if so, how do I tell trainnet() that X is the input to be used for network prediction and that (T,W) are constant data? Does trainnet() always assume only the first datastore in cds are the predictors?
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!