ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CrossEntropy.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#include "
train/losses_functions/CrossEntropy.h
"
18
19
using namespace
onert_micro
;
20
using namespace
onert_micro::train
;
21
using namespace
onert_micro::train::losses_functions
;
22
23
/*
24
* dE/dY = Y_t / Y
25
* where Y - vector of calculated outputs,
26
* Y_t - vector of target outputs
27
* Note: size of Y and Y_t should be the same and equal to flat_size
28
*/
29
void
CrossEntropy::calculateErrorBackpropagation
(
const
uint32_t flat_size,
30
const
float
*calculated_data,
31
const
float
*target_data,
float
*output_grad)
32
{
33
for
(uint32_t i = 0; i < flat_size; ++i)
34
{
35
output_grad[i] = -1.f * target_data[i] / (calculated_data[i] + float(10.0e-32));
36
}
37
}
CrossEntropy.h
onert_micro::train::losses_functions
Definition
CrossEntropy.h:29
onert_micro::train
Definition
PALConv2DInputGrad.h:28
onert_micro
Definition
OMMemoryManager.h:26
onert_micro::train::losses_functions::CrossEntropy::calculateErrorBackpropagation
static void calculateErrorBackpropagation(const uint32_t flat_size, const float *calculated_data, const float *target_data, float *output_grad)
Definition
CrossEntropy.cpp:29
onert-micro
onert-micro
src
train
losses_functions
CrossEntropy.cpp
Generated by
1.9.8