激活函数实现–4 Rectified linear函数实现

激活函数实现–4 Rectified linear函数实现1 RectifiedLin 函数的定义 2 RectifiedLin 函数的导数 3 RectifiedLin 函数的实现 Rectifiedlin 主要是通过类 RectifiedLin 来实现的 该类继承自 AbstrcactAct 类 主要实现 Activ

1.Rectified Linear函数的定义

激活函数实现--4 Rectified linear函数实现激活函数实现--4 Rectified linear函数实现


激活函数实现--4 Rectified linear函数实现







2.Rectified Linear函数的导数

激活函数实现--4 Rectified linear函数实现
激活函数实现--4 Rectified linear函数实现













3.Rectified Linear函数的实现

Rectified linear主要是通过类RectifiedLinear来实现的,该类继承自AbstrcactActivation类,主要实现Activating接口和Derivating接口。

RectifiedLinear类的定义如下:

#ifndef RECTIFIEDLINEAR_H #define RECTIFIEDLINEAR_H #include "abstractactivationfunction.h" / * @brief The RectifiedLinear class used to calculate the rectified linear * activation function. * * @author sheng * @date 2014-07-23 * @version 0.1 * * @history *                              * sheng 2014-07-23 0.1 build the class * */ class RectifiedLinear : public AbstractActivationFunction { public: RectifiedLinear(); cv::Mat Activating(const cv::Mat &InputMat); cv::Mat Derivating(const cv::Mat &InputMat); }; #endif // RECTIFIEDLINEAR_H                      

 

 

函数的定义如下:





#include "rectifiedlinear.h" / * @brief The default constructor. * * @author sheng * @version 0.1 * @date 2014-07-23 * * @history * 
    
     
      
      
        * sheng 2014-07-23 0.1 build the function */ RectifiedLinear::RectifiedLinear() { } / * @brief Calculating the rectified linear of the inputmat. * @param InputMat The input mat * @return the result of rectifiedlinear(inputmat), whose size is the same of the * InputMat. * * * @author sheng * @version 0.1 * @date 2014-07-23 * * @history * 
        
         
          
          
            * sheng 2014-07-23 0.1 build the function * */ cv::Mat RectifiedLinear::Activating(const cv::Mat &InputMat) { // convert to float mat cv::Mat FloatMat = ConvertToFloatMat(InputMat); // calculate the rectified linear cv::Mat Result; cv::threshold(FloatMat, Result, 0.0, 255, cv::THRESH_TOZERO); return Result; } / * @brief Calculating the derivative of the rectifiedlinear. * @param InputMat The input mat * @return the result of the derivative of the rectifiedlinear, whose size is * the same of the InputMat. * * * @author sheng * @version 0.1 * @date 2014-07-23 * * @history * 
            
             
              
              
                * sheng 2014-07-23 0.1 build the function * */ cv::Mat RectifiedLinear::Derivating(const cv::Mat &InputMat) { // convert to float mat cv::Mat FloatMat = ConvertToFloatMat(InputMat); // calculate which element of the mat is bigger or equal to zero. cv::Mat TmpResult = FloatMat >= 0.0; // calculate the derivate of the rectified linear cv::Mat Result = TmpResult & 1; return Result; } 
               
              
             
            
           
          
         
        
       
      
     
   





版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/218442.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月18日 上午7:14
下一篇 2026年3月18日 上午7:15


相关推荐

  • java 滤波算法_双边滤波算法

    java 滤波算法_双边滤波算法1、原理高斯滤波是以距离为权重,设计滤波模板作为滤波系数,只考虑了像素间的空间位置上的关系,因此滤波的结果会丢失边缘的信息。高斯滤波的缺陷如下图所示:平坦区域正常滤波,图像细节没有变化,而在突变的边缘上,因为只使用了距离来确定滤波权重,导致边缘被模糊。在高斯基础上,进一步优化,叠加了像素值的考虑,因此也就引出了双边滤波,一种非线性滤波,滤波效果对保留边缘更有效。为了理解双边滤波的距离和像素差两个影…

    2022年5月29日
    40
  • C#调用WebService实例和开发「建议收藏」

    C#调用WebService实例和开发「建议收藏」C#调用WebService实例和开发一、基本概念  WebService也叫XMLWebServiceWebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求,轻量级的独立的通讯技术。是:通过SOAP在Web上提供的软件服务,使用WSDL文件进行说明,并通过UDDI进行注册。简单的理解就是:webservice就是放在服务器上的函数,所…

    2022年7月21日
    19
  • 全球第一!腾讯混元翻译模型Hunyuan-MT-7B登顶开源热榜

    全球第一!腾讯混元翻译模型Hunyuan-MT-7B登顶开源热榜

    2026年3月12日
    2
  • 计算文本相似度的常用算法

    计算文本相似度的常用算法NLP 数据挖掘领域中 文本分析是一个很重要的领域 这有助于我们去让计算机理解语言的作用和使用 文本分析是数据挖掘的重要手段 利用文本分析 我们将很快的读取到一本书 一篇文章 一段话中的关键词和核心思想 而文本相似度就是我们用来剔除无用信息或者重复信息的重要手段 让计算机去找文本中的不同 在生活中 信息检索 数据挖掘 机器翻译 文档复制检测等领域都应用到 文本相似度 文本不仅仅是文字 文本相似度的应用更广 除了文字的匹配 还可以是图片 音频等 因为它们的实质都是在计算机中都是以二进制的方式存在的 相

    2026年3月18日
    2
  • Linux SSHFS挂载验证-海思Linux系统

    Linux SSHFS挂载验证-海思Linux系统内核支持 CONFIG FUSE FS 查看 cat proc filesystemsn sysfsnodev rootfsnodev ramfsnodev bdevnodev procnodev cgroupnodev tmpfsnodev devtmpfsnode sockfsnodev pipefsnodev rpc pipefsnodev devpts ext3 ext2 ext4 cramfs vfat msdos

    2026年3月18日
    2
  • utc时间戳转换器_java时间转字符串

    utc时间戳转换器_java时间转字符串StringutcStr=”ThuAug1416:45:37UTC2011″;Datedate=newDate(utcStr);SimpleDateFormatsf=newSimpleDateFormat(“yyyy-MM-dd”);sf.format(date);

    2022年10月3日
    5

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号