Apache POI HSSF读写Excel总结

离合器KP点自学习:从原理到工程实践的全景解析 本文全面解析了离合器KP点自学习的原理与工程实践,详细介绍了KP点的物理本质、控制价值及自学习方法。通过扭矩增量式和转速变化式学习法,结合不同变速箱构型的适配策略,提升离合器控制的精度与效率。文章还探讨了液压系统迟滞补偿和摩擦材料老化应对方案,为工程实践提供可靠保障。 阅读详情

Apache POI HSSF和XSSF读写EXCEL总结 
HSSF是指2007年以前的,XSSF是指2007年版本以上的 
这个还是比较好用的,这些总结来自Apache的官方向导的点点滴滴 
还有好多没有没有写的,详细的请参考http://poi.apache.org/spreadsheet/quick-guide.html 
还有LOG也比较好看 
 

Java代码 
  1. public class SummaryHSSF {  
  2.   
  3.     public static void main(String[] args) throws IOException {  
  4.         //创建Workbook对象(这一个对象代表着对应的一个Excel文件)  
  5.                      //HSSFWorkbook表示以xls为后缀名的文件  
  6.         Workbook wb = new HSSFWorkbook();  
  7.         //获得CreationHelper对象,这个应该是一个帮助类  
  8.         CreationHelper helper = wb.getCreationHelper();  
  9.         //创建Sheet并给名字(表示Excel的一个Sheet)  
  10.         Sheet sheet1 = wb.createSheet("HSSF_Sheet_1");        
  11.         Sheet sheet2 = wb.createSheet("HSSF_Sheet_2");  
  12.         //Row表示一行Cell表示一列  
  13.         Row row = null;  
  14.         Cell cell = null;  
  15.         for(int i=0;i<60;i=i+2){  
  16.             //获得这个sheet的第i行  
  17.             row = sheet1.createRow(i);  
  18.             //设置行长度自动             
  19.             //row.setHeight((short)500);  
  20.             row.setHeightInPoints(20);  
  21.             //row.setZeroHeight(true);  
  22.             for(int j=0;j<25;j++){         
  23.                 //设置每个sheet每一行的宽度,自动,根据需求自行确定  
  24.                 sheet1.autoSizeColumn(j+1, true);  
  25.                 //创建一个基本的样式  
  26.                 CellStyle cellStyle = SummaryHSSF.createStyleCell(wb);  
  27.                 //获得这一行的每j列  
  28.                 cell = row.createCell(j);  
  29.                 if(j==0){  
  30.                     //设置文字在单元格里面的位置  
  31.                     cellStyle = SummaryHSSF.setCellStyleAlignment(cellStyle, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);  
  32.                     //先创建字体样式,并把这个样式加到单元格的字体里面  
  33.                     cellStyle.setFont(createFonts(wb));  
  34.                     //把这个样式加到单元格里面  
  35.                     cell.setCellStyle(cellStyle);                     
  36.                     //给单元格设值  
  37.                     cell.setCellValue(true);  
  38.                 }else if(j==1){  
  39.                     //设置文字在单元格里面的位置  
  40.                     cellStyle = SummaryHSSF.setCellStyleAlignment(cellStyle, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);  
  41.                     //设置这个样式的格式(Format)  
  42.                     cellStyle = SummaryHSSF.setCellFormat(helper,cellStyle, "#,##0.0000");                    
  43.                     //先创建字体样式,并把这个样式加到单元格的字体里面  
  44.                     cellStyle.setFont(createFonts(wb));  
  45.                     //把这个样式加到单元格里面  
  46.                     cell.setCellStyle(cellStyle);  
  47.                     //给单元格设值  
  48.                     cell.setCellValue(new Double(2008.2008));  
  49.                 }else if(j==2){  
  50.                     cellStyle = SummaryHSSF.setCellStyleAlignment(cellStyle, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);                      
  51.                     cellStyle.setFont(createFonts(wb));  
  52.                     cell.setCellStyle(cellStyle);  
  53.                     cell.setCellValue(helper.createRichTextString("RichString"+i+j));                     
  54.                 }else if(j==3){  
  55.                     cellStyle = SummaryHSSF.setCellStyleAlignment(cellStyle, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);  
  56.                     cellStyle = SummaryHSSF.setCellFormat(helper,cellStyle, "MM-yyyy-dd");  
  57.                     cell.setCellStyle(cellStyle);  
  58.                     cell.setCellValue(new Date());  
  59.                 }else if(j==24){  
  60.                     cellStyle = SummaryHSSF.setCellStyleAlignment(cellStyle, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);  
  61.                     cellStyle.setFont(createFonts(wb));  
  62.                     //设置公式  
  63.                     cell.setCellFormula("SUM(E"+(i+1)+":X"+(i+1)+")");                    
  64.                 }else{                    
  65.                     cellStyle = SummaryHSSF.setCellStyleAlignment(cellStyle, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);  
  66.                     cellStyle = SummaryHSSF.setFillBackgroundColors(cellStyle,IndexedColors.ORANGE.getIndex(),IndexedColors.ORANGE.getIndex(),CellStyle.SOLID_FOREGROUND);  
  67.                     cell.setCellStyle(cellStyle);  
  68.                     cell.setCellValue(1);  
  69.                 }  
  70.             }  
  71.         }  
  72.         //输出  
  73.         OutputStream os = new FileOutputStream(new File("c://SummaryHSSF.xls"));  
  74.         wb.write(os);  
  75.         os.close();       
  76.     }  
  77.     /** 
  78.      * 边框 
  79.      * @param wb 
  80.      * @return 
  81.      */  
  82.     public static CellStyle createStyleCell(Workbook wb){  
  83.         CellStyle cellStyle = wb.createCellStyle();  
  84.         //设置一个单元格边框颜色  
  85.         cellStyle.setBorderBottom(CellStyle.BORDER_THIN);  
  86.         cellStyle.setBorderTop(CellStyle.BORDER_THIN);  
  87.         cellStyle.setBorderLeft(CellStyle.BORDER_THIN);  
  88.         cellStyle.setBorderRight(CellStyle.BORDER_THIN);  
  89.         //设置一个单元格边框颜色  
  90.         cellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());  
  91.         cellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());  
  92.         cellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());  
  93.         cellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());          
  94.         return cellStyle;  
  95.     }  
  96.     /** 
  97.      * 设置文字在单元格里面的位置 
  98.      * CellStyle.ALIGN_CENTER 
  99.      * CellStyle.VERTICAL_CENTER 
  100.      * @param cellStyle 
  101.      * @param halign 
  102.      * @param valign 
  103.      * @return 
  104.      */  
  105.     public static CellStyle setCellStyleAlignment(CellStyle cellStyle,short halign,short valign){  
  106.         //设置上下  
  107.         cellStyle.setAlignment(CellStyle.ALIGN_CENTER);  
  108.         //设置左右  
  109.         cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);  
  110.         return cellStyle;  
  111.     }  
  112.     /** 
  113.      * 格式化单元格 
  114.      * 如#,##0.00,m/d/yy去HSSFDataFormat或XSSFDataFormat里面找 
  115.      * @param cellStyle 
  116.      * @param fmt 
  117.      * @return 
  118.      */  
  119.     public static CellStyle setCellFormat(CreationHelper helper,CellStyle cellStyle,String fmt){  
  120.         //还可以用其它方法创建format  
  121.         cellStyle.setDataFormat(helper.createDataFormat().getFormat(fmt));  
  122.         return cellStyle;  
  123.     }  
  124.     /** 
  125.      * 前景和背景填充的着色 
  126.      * @param cellStyle 
  127.      * @param bg IndexedColors.ORANGE.getIndex(); 
  128.      * @param fg IndexedColors.ORANGE.getIndex(); 
  129.      * @param fp CellStyle.SOLID_FOREGROUND 
  130.      * @return 
  131.      */  
  132.     public static CellStyle setFillBackgroundColors(CellStyle cellStyle,short bg,short fg,short fp){  
  133.         //cellStyle.setFillBackgroundColor(bg);  
  134.         cellStyle.setFillForegroundColor(fg);  
  135.         cellStyle.setFillPattern(fp);  
  136.         return cellStyle;  
  137.     }  
  138.     /** 
  139.      * 设置字体 
  140.      * @param wb 
  141.      * @return 
  142.      */  
  143.     public static Font createFonts(Workbook wb){  
  144.         //创建Font对象  
  145.         Font font = wb.createFont();  
  146.         //设置字体  
  147.         font.setFontName("黑体");  
  148.         //着色  
  149.         font.setColor(HSSFColor.BLUE.index);  
  150.         //斜体  
  151.         font.setItalic(true);  
  152.         //字体大小  
  153.         font.setFontHeight((short)300);  
  154.         return font;  
  155.     }  
  156. }  

读取Excel文件 
Java代码 
  1. public class ReadExcel {  
  2.     public static void main(String[] args) throws Exception {  
  3.         InputStream is = new FileInputStream(new File("c://SummaryHSSF.xls"));  
  4.         //根据输入流创建Workbook对象  
  5.         Workbook wb = WorkbookFactory.create(is);  
  6.         //get到Sheet对象  
  7.         Sheet sheet = wb.getSheetAt(0);  
  8.         //这个必须用接口  
  9.         for(Row row : sheet){  
  10.             for(Cell cell : row){  
  11.                 //cell.getCellType是获得cell里面保存的值的type  
  12.                 //如Cell.CELL_TYPE_STRING  
  13.                 switch(cell.getCellType()){  
  14.                     case Cell.CELL_TYPE_BOOLEAN:  
  15.                         //得到Boolean对象的方法  
  16.                         System.out.print(cell.getBooleanCellValue()+" ");  
  17.                         break;  
  18.                     case Cell.CELL_TYPE_NUMERIC:  
  19.                         //先看是否是日期格式  
  20.                         if(DateUtil.isCellDateFormatted(cell)){  
  21.                             //读取日期格式  
  22.                             System.out.print(cell.getDateCellValue()+" ");  
  23.                         }else{  
  24.                             //读取数字  
  25.                             System.out.print(cell.getNumericCellValue()+" ");  
  26.                         }  
  27.                         break;  
  28.                     case Cell.CELL_TYPE_FORMULA:  
  29.                         //读取公式  
  30.                         System.out.print(cell.getCellFormula()+" ");  
  31.                         break;  
  32.                     case Cell.CELL_TYPE_STRING:  
  33.                         //读取String  
  34.                         System.out.print(cell.getRichStringCellValue().toString()+" ");  
  35.                         break;                    
  36.                 }  
  37.             }  
  38.             System.out.println("");  
  39.         }  
  40.     }  
  41. }  


还有一种传统的读法 
Java代码 
  1. Sheet sheet = wb.getSheetAt(0);  
  2.     for (Iterator rit = sheet.rowIterator(); rit.hasNext(); ) {  
  3.         Row row = (Row)rit.next();  
  4.         for (Iterator cit = row.cellIterator(); cit.hasNext(); ) {  
  5.             Cell cell = (Cell)cit.next();  
  6.             // Do something here  
  7.         }  
  8.     }  
  9.                     HSSFSheet sheet = wb.getSheetAt(0);  
  10.     for (Iterator<HSSFRow> rit = (Iterator<HSSFRow>)sheet.rowIterator(); rit.hasNext(); ) {  
  11.         HSSFRow row = rit.next();  
  12.         for (Iterator<HSSFCell> cit = (Iterator<HSSFCell>)row.cellIterator(); cit.hasNext(); ) {  
  13.             HSSFCell cell = cit.next();  
  14.             // Do something here  
  15.         }  
  16.     }  
【固态变压器(SST)全维度解析】发展历史、技术、玩家、挑战与数据中心趋势 SST正处于技术突破向规模化商用的关键过渡期,随着SiC/GaN器件降价、标准完善、可靠性数据积累,其在数据中心的渗透率将快速提升。短期(2025 - 2027年)以示范项目为主,中长期(2030年后)有望成为超大规模智算中心的主流供电方案。 阅读详情

相关推荐

NCBI Datasets CLI优化:解决基因组数据下载报错与速度问题

基因组数据下载是生物信息学分析的关键环节,其稳定性和效率直接影响研究进度。NCBI Datasets CLI作为官方命令行工具,常面临连接中断和下载速度慢两大痛点,这主要源于服务器连接限制和网络传输问题。通过自动重试机制和校验修复流程可提升稳定性,而连接复用与CDN加速等技术能显著提高下载效率。在植物基因组等大规模数据场景中,结合脱水模式和增量更新策略可减少70%传输量。本文以艾草基因组项目为例,展示如何通过并行下载和API优化将100个基因组的下载时间从18小时缩短至2小时,为生物信息学研究提供可靠的数据

weixin_29051245的博客 250

apache poi 实现简单的excel合并单元格读取

poi处理简单的excel合并单元格数据

m0_56069088的博客 2147

clumsy一款模拟弱网的工具

利用封装 Winodws Filtering Platform 的WinDivert 库, clumsy 能实时的将系统接收和发出的网络数据包拦截下来,人工的造成延迟,掉包和篡改操作后再进行发送。无论你是要重现网络异常造成的程序错误,还是评估你的应用程序在不良网络状况下的表现,clumsy 都能让你在不需要额外添加代码的情况下,在系统层次帮你达到想要的效果。

klb5555的专栏 2566

Java利用POI:HSSF、XSSF、SXSSF操作Excel

Java利用POI操作Excel POI提供了HSSF、XSSF以及SXSSF三种方式操作Excel。 其中: HSSF:Excel97-2003版本,扩展名为.xls。一个sheet最大行数65536,最大列数256。 XSSF:Excel2007版本开始,扩展名为.xlsx。一个sheet最大行数1048576,最大列数16384。 SXSSF:是在XSSF基础上,POI3.8版本开始提供的支持低内存占用的操作方式,扩展名为.xlsx。 SXSSF支持低内存占用的方式是,通过一个滑动窗口来限制访问Row

大数据开发、JAVA开发、人工智能AI 7143

蓝桥杯STM32 G431 hal库开发速成——GPIO输入——按键长短按,按键单双击

将TIM与GPIO输入(按键)结合起来使用,很好的练习项目。按键长短按,按键单双击。STM32定时器常见问题

weixin_44860466的博客 2619

基于Ardupilot/PX4固件,APM/PIXhawk硬件的VTOL垂直起降固定翼软硬件参数调试(第一篇)安装调试

基于Ardupilot/PX4固件,APM/PIXhawk硬件的VTOL垂直起降固定翼调试 本文内容大部分来自Kris,我们的K大,在VTOL领域的大牛,在此,非常感谢K大。能引用K大的成果也是自己的荣幸,不便之处还请K大多多包涵,在此引用只是为方便自己日常学习,部分参数表里根据自身情况,增加了相应参数。 1.安装及下载Ardupilot官方固件: VTOL固件的来源可分为Ardupilot官方固...

u011322358的博客 3万+

apache.poi读取.xls文件时The content of an excel record cannot exceed 8224 bytes

写入的,我的文件修改步骤是先删除页签然后写入页签(页签名是保持不变的),这样一次修改的结果也是符合我的预期的,但是某次程序读取文件时就出现了下面的报错,而且手动也打不开文件了。我在构造函数打了一个断点,发现每当删除一个页签或者新增一个页签就会创建RefSubRecord页签。版本,我尝试升级为3.8版本的时候发现就没有这个问题了,原因是再3.8中删除的删除的页签的时候不会修改RefSubRecord的信息。这里有意思的是删除页签的时候会把对应索引的记录的。待读取的文件的内容也是通过。(少了上面红框的内容)

ycd500756的博客 955

Linux服务器上后台运行jupyter notebook/Lab

1 安装配置教程2 后台运行jupyter3 更改运行环境kernel4 SSH端口转发 1 安装配置教程 可以参考:https://www.cnblogs.com/thousfeet/p/10647102.html 2 后台运行jupyter screen -S jupyter # 新建一个名为jupyter的后台screen # 在base环境下,先 cd 到指定文件目录 jupyter notebook # or jupyter lab 3 更改运行环境kernel 需要手动为每个环境添加内.

strivequeen的博客 1838

java poi 读合并单元格的内容,POI-java读取Excel(包含合并单元格)

importorg.apache.poi.hssf.usermodel.HSSFWorkbook;importorg.apache.poi.ss.usermodel.Cell;importorg.apache.poi.ss.usermodel.Row;importorg.apache.poi.ss.usermodel.Sheet;importorg.apache.poi.ss.usermodel....

weixin_27061475的博客 530

Windows报无法成功完成操作,因为文件包含病毒或潜在的垃圾软件的解决方法

Windows报无法成功完成操作,因为文件包含病毒或潜在的垃圾软件的解决方法 在Windows的搜索框中输入Windows安全中心,搜索到后将其打开 点击病毒和威胁防护将鼠标移动到Microsoft Defender防病毒选项处,将定期扫描打开 下滑找到管理设置 先关闭篡改防护,再点击添加或删除排除项 先点击添加排除项,再点击文件,选择报出异常的文件,将其添加到排除项中,过程中会存在跳框确认,皆点击确定,完成后就可以运行报无法成功完成操作,因为文件包含病毒或潜在的垃圾软件异常的文件

123 2万+

【2026年华为暑期实习(AI)-4月29日-第一题- 选择题】(题目+思路+Java&C++&Python解析+在线测试)

本文摘要涵盖了机器学习和深度学习中的多个核心概念与技术,包括非负矩阵分解、条件数、MobileNet创新点、LDA降维、大模型评测指标、半精度训练、多任务学习、GPU存储层次、正则化、张量并行等。通过12道单选题和8道多选题的形式,系统性地考察了相关理论原理、应用场景及工程实践要点。题目设计注重概念准确性(如LDA目标函数)、技术细节(如Megatron-LM的并行策略)与实际应用(如FP16训练动机),并包含概率统计(二项分布)和数值计算(微分误差分析)等数学基础内容,全面检验读者对AI领域关键知识的掌握

m0_73659489的博客 144

java用org.apache.poi包操作excel

一.POI简介Jakarta POI 是apache的子项目,目标是处理ole2对象。它提供了一组操纵Windows文档的Java API目前比较成熟的是HSSF接口,处理MS Excel(97-2002)对象。它不象我们仅仅是用csv生成的没有格式的可以由Excel转换的东西,而是真正的Excel对象,你可以控制一些属性如sheet,cell等等。二.HSSF

如是所来的专栏 5万+

原理和代码解读:用Diffusion Models高清图像修复(Image Inpainting)

在最近的Diffusion Models应用中,Image Inpainting+ControlNet/Lora等工作在模特衣服生成、家居场景重建等场景中得到了广泛的应用。这篇博客主要介绍Diffusion Models如何在修复高清图像的。

沉迷单车的追风少年 2499

Apache POI HSSF和XSSF读写EXCEL总结

Apache POI HSSF和XSSF读写EXCEL总结 HSSF是指2007年以前的,XSSF是指2007年版本以上的 这个还是比较好用的,这些总结来自Apache的官方向导的点点滴滴 还有好多没有没有写的,详细的请参考http://poi.apache.org/spreadsheet/quick-guide.html 还有LOG也比较好看 Java代码 [c...

sunrenen的博客 287

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

【Apache POI】Excel操作(一):Excel本地写入基本操作的实现

相信大家在开发的过程中难免遇到要进行Excel操作的任务,接下来我会出一系列关于如何用Java操作Excel的博客教程,欢迎有需要的小伙伴持续关注哦!

Qizhi_Hu的博客 2159

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

POI - 简单读写Excel

官网地址:https://poi.apache.org/ 基本功能: HSSF — 提供读写Microsoft Excel格式文档的功能。(2003版,最多只能存65536行数据) XSSF — 提供读写Microsoft Excel OOXML格式文档的功能。(2007版,可存放的数据无限制) 1. POI - Excel写 1.1 相关依赖: <!-- xls(2003) --> <dependency> <groupId>org.apache.poi&l

luobi1995的博客 693

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

使用POI读写excel

POI介绍 Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能。 HSSF - 提供读写Microsoft Excel格式档案的功能。 XSSF - 提供读写MicrosoftExcelOOXML格式档案的功能。 HWPF - 提供读写Microsoft Word格式档案的功能。 HSLF...

大头皮鞋的博客 1527
上一篇: AXIS2发布WebService
下一篇: java操作excel(HSSF样式一) 【转】
siming861022
博客等级 码龄17年 1粉丝 2原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值