Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
LossFunctions.cu
Go to the documentation of this file.
1// @(#)root/tmva/tmva/dnn:$Id$
2// Author: Simon Pfreundschuh 13/07/16
3
4/*************************************************************************
5 * Copyright (C) 2016, Simon Pfreundschuh *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12///////////////////////////////////////////////////////////////////////
13// Implementation of the loss functions for the TCuda implementation //
14// of the low-level interface. //
15///////////////////////////////////////////////////////////////////////
16
19
20
21namespace TMVA
22{
23namespace DNN
24{
25
26//____________________________________________________________________________
27template<typename AFloat>
30 const TCudaTensor<AFloat> & weights)
31{
32 return TCuda<AFloat>::MeanSquaredError(Y.GetMatrix(), output.GetMatrix(), weights.GetMatrix());
33}
34
35//____________________________________________________________________________
36template<typename AFloat>
38 const TCudaTensor<AFloat> & Y,
40 const TCudaTensor<AFloat> &weights)
41{
42 TCudaMatrix<AFloat> mdY = dY.GetMatrix();
43 TCuda<AFloat>::MeanSquaredErrorGradients(mdY, Y.GetMatrix(), output.GetMatrix(), weights.GetMatrix());
44}
45
46//____________________________________________________________________________
47template<typename AFloat>
50 const TCudaTensor<AFloat> &weights)
51{
52 return TCuda<AFloat>::CrossEntropy(Y.GetMatrix(), output.GetMatrix(), weights.GetMatrix());
53}
54
55//____________________________________________________________________________
56template<typename AFloat>
58 const TCudaTensor<AFloat> & Y,
60 const TCudaTensor<AFloat> &weights)
61{
62 TCudaMatrix<AFloat> mdY = dY.GetMatrix();
63 TCuda<AFloat>::CrossEntropyGradients(mdY, Y.GetMatrix(), output.GetMatrix(), weights.GetMatrix());
64}
65
66//____________________________________________________________________________
67template<typename AFloat>
70 const TCudaTensor<AFloat> &weights)
71{
72 return TCuda<AFloat>::SoftmaxCrossEntropy(Y.GetMatrix(), output.GetMatrix(), weights.GetMatrix());
73}
74
75//____________________________________________________________________________
76template<typename AFloat>
78 const TCudaTensor<AFloat> & Y,
80 const TCudaTensor<AFloat> &weights)
81{
82 TCudaMatrix<AFloat> mdY = dY.GetMatrix();
83 TCuda<AFloat>::SoftmaxCrossEntropyGradients(mdY, Y.GetMatrix(), output.GetMatrix(), weights.GetMatrix());
84}
85
86} // namespace DNN
87} // namespace TMVA
static Scalar_t CrossEntropy(const Matrix_t &Y, const Matrix_t &output, const Matrix_t &weights)
Sigmoid transformation is implicitly applied, thus output should hold the linear activations of the l...
static void MeanSquaredErrorGradients(Matrix_t &dY, const Matrix_t &Y, const Matrix_t &output, const Matrix_t &weights)
static Scalar_t MeanSquaredError(const Matrix_t &Y, const Matrix_t &output, const Matrix_t &weights)
static Scalar_t SoftmaxCrossEntropy(const Matrix_t &Y, const Matrix_t &output, const Matrix_t &weights)
Softmax transformation is implicitly applied, thus output should hold the linear activations of the l...
static void CrossEntropyGradients(Matrix_t &dY, const Matrix_t &Y, const Matrix_t &output, const Matrix_t &weights)
static void SoftmaxCrossEntropyGradients(Matrix_t &dY, const Matrix_t &Y, const Matrix_t &output, const Matrix_t &weights)
create variable transformations
static void output()