#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric> double myfunction(double num) {
return exp(num);
} template <typename T>
void softmax(const typename::std::vector<T> &v, typename::std::vector<T> &s){
double sum=0.0;
transform(v.begin(), v.end(), s.begin(), myfunction);
sum=accumulate(s.begin(), s.end(), sum);
for(size_t i=; i<s.size(); ++i)
s.at(i)/=sum;
} int main() {
double a[]={1.0, 3.0, 2.0};
std::vector<double> v_a(a, a+sizeof a/sizeof a[]), v_b(v_a);
std::vector<double>::const_iterator it=v_a.begin();
for(; it!=v_a.end(); ++it) {
std::cout<<*it<<" ";
}
std::cout<<std::endl;
softmax(v_a, v_b);
it=v_b.begin();
for(; it!=v_b.end(); ++it) {
std::cout<<*it<<" ";
}
std::cout<<std::endl;
return ;
}

最新文章

  1. HTML5在canvas中绘制复杂形状附效果截图
  2. 使用WebKit.net加载HTML编辑器
  3. Codeforces 682C Alyona and the Tree(树形DP)
  4. ViewHolder简洁写法
  5. Vue 模板
  6. Unity3D的杂记
  7. WCF z
  8. 开发板上修改时间方法date命令【转】
  9. w5cValidator【AngularJS】 2.0 版本发布
  10. Unity3D中使用MiniJson解析json的例子
  11. Linux使用ssh公钥实现免批量分发管理服务器
  12. xshell连接centos与ubuntu
  13. Unity进阶----Lua语言知识点(2018/11/08)
  14. &#127827; vue循环渲染本地图片不显示? &#127827;
  15. [亲测哪步都不能省可用]联想ThinkPad E450装系统后开机一直停留在BootMenu上,无法选择硬盘进入
  16. spring boot 的maven设置阿里云仓库
  17. Java Web之HTML5
  18. 【C++】 网络编程 01
  19. keras 设置GPU使用率
  20. 台式电脑、笔记本快捷选择启动项Boot 快捷键大全

热门文章

  1. Python之面向对象上下文管理协议
  2. random,json,pickle,hashlib,shutil,hmac,shelve 模块
  3. 基础知识:if条件、while循环、for循环 相关练习
  4. 二元决策图(Binary decision diagram)
  5. 测试各种低价VPS
  6. [codevs4655] 序列终结者(Splay)
  7. vim fulerformat的设置
  8. operamasks-omGrid的使用
  9. Eclipse错误:Syntax error on tokens, delete these tokens问题解决
  10. Servlet的Cookies处理