bool training) {
auto &hidden_ = context.getOutput(SINGLE_INOUT_IDX);
auto &input_ = context.getInput(SINGLE_INOUT_IDX);
- auto &label = context.getLabel(SINGLE_INOUT_IDX);
const auto &input_dim = input_.getDim();
- if (training && label.empty()) {
- throw std::invalid_argument(
- "[CentroidKNN] forwarding requires label feeded");
- }
-
auto &map = context.getWeight(weight_idx[KNNParams::map]);
auto &num_samples = context.getWeight(weight_idx[KNNParams::num_samples]);
auto feature_len = input_dim.getFeatureLen();
};
if (training) {
+ auto &label = context.getLabel(SINGLE_INOUT_IDX);
auto ans = label.argmax();
for (unsigned int b = 0; b < input_.batch(); ++b) {
* @brief This is the layer context for each layer
*/
+#include "nntrainer_error.h"
#include <functional>
#include <layer_context.h>
Tensor &RunLayerContext::getLabel(unsigned int idx) {
if (isLabelAvailable(idx))
return outputs[idx]->getGradientRef();
- else
- throw std::invalid_argument("Request tensor which does not exist");
+ else {
+ std::stringstream ss;
+ ss << "Requesing label of index: " << idx << "for " << getName()
+ << " does not exist";
+ throw std::invalid_argument(ss.str().c_str());
+ }
}
/**