You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/05/17 22:28:20 UTC

[GitHub] [tvm] altanh commented on a change in pull request #8056: [Relay, TOPI] Add negative log likelihood loss (nll_loss) op

altanh commented on a change in pull request #8056:
URL: https://github.com/apache/tvm/pull/8056#discussion_r633907154



##########
File path: include/tvm/topi/nn.h
##########
@@ -642,6 +643,54 @@ inline tvm::te::Tensor batch_to_space_nd(const tvm::te::Tensor& data,
   out = strided_slice(out, begin_idx, end_idx, strides);
   return out;
 }
+
+/*!
+ * \brief Negative log likelihood loss.
+ *
+ * \param input The input tensor.
+ * \param target The target tensor.
+ * \param weight A manual rescaling weight given to each class.
+ * \param reduction The reduction method to apply to the output.
+ * \param ignore_index The target value to ignore.
+ * \param name The name of the operation.
+ * \param tag The tag to mark the operation.
+ *
+ * \return A Tensor whose op member is the batch_to_space_nd operation
+ */
+inline Tensor nll_loss(const Tensor& input, const Tensor& target, const Tensor& weight,
+                       std::string reduction = "mean", int ignore_index = -100,

Review comment:
       I believe this is the default used in PyTorch, there's no inherent significance to it (although certain data loading/preprocessing scripts seem to try and match this value - e.g. I've see this in certain BERT training data loaders)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org