diff --git a/doc/implements.rst b/doc/implements.rst index 4bec770f46..cf61e808b8 100644 --- a/doc/implements.rst +++ b/doc/implements.rst @@ -175,6 +175,9 @@ Function Implements - x - * - HuberLoss + - x + - + * - EpsilonInsensitiveLoss - x - * - SigmoidCrossEntropy diff --git a/include/nbla/cuda/function/epsilon_insensitive_loss.hpp b/include/nbla/cuda/function/epsilon_insensitive_loss.hpp new file mode 100644 index 0000000000..f67f8465c9 --- /dev/null +++ b/include/nbla/cuda/function/epsilon_insensitive_loss.hpp @@ -0,0 +1,31 @@ +// Copyright (c) 2017 Sony Corporation. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** EpsilonInsensitiveLoss + */ +#ifndef __NBLA_CUDA_FUNCTION_EPSILONINSENSITIVELOSS_HPP__ +#define __NBLA_CUDA_FUNCTION_EPSILONINSENSITIVELOSS_HPP__ + +#include +#include +#include +#include + +namespace nbla { +/** @copydoc EpsilonInsensitiveLoss +*/ +NBLA_DECLARE_TRANSFORM_BINARY_CUDA_1(EpsilonInsensitiveLoss, float); +} + +#endif diff --git a/src/nbla/cuda/function/epsilon_insensitive_loss.cu b/src/nbla/cuda/function/epsilon_insensitive_loss.cu new file mode 100644 index 0000000000..1cdd82766f --- /dev/null +++ b/src/nbla/cuda/function/epsilon_insensitive_loss.cu @@ -0,0 +1,31 @@ +// Copyright (c) 2017 Sony Corporation. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include +#include +#include + +namespace nbla { + +NBLA_DEFINE_TRANSFORM_BINARY_CUDA_1( + EpsilonInsensitiveLoss, + (fabs(x0 - x1) > (T)a0) ? (fabs((x0 - x1)) - (T)a0) : (T)0, + (x0 - x1) > (T)a0 ? dy : ((x0 - x1) < (T)-a0) ? -dy : (T)0, + (x0 - x1) > (T)a0 ? -dy : ((x0 - x1) < (T)-a0) ? dy : (T)0, float); +// template instantiation +template class EpsilonInsensitiveLossCuda; +}