Torch7学习笔记[2] ---神经网络的主体框架
2016-08-30 22:06
316 查看
参考资料:
https://github.com/soumith/cvpr2015/blob/master/Deep%20Learning%20with%20Torch.ipynb
将整个框架分为以下几个模块:
1、options设置
2、train、test预处理以及读取
3、net结构以及criterion建立
4、train设置
5、test设置
6、保存中间结果以及断点开始(待完善)
y以上每个功能模块单独由一个文件完成,整个结构分为7个文件
运行程序时,直接在文件所在目录终端执行:th main.lua 即可运行程序。若需改变options,例如gpu运行:th main.lua –type cuda
https://github.com/soumith/cvpr2015/blob/master/Deep%20Learning%20with%20Torch.ipynb
将整个框架分为以下几个模块:
1、options设置
2、train、test预处理以及读取
3、net结构以及criterion建立
4、train设置
5、test设置
6、保存中间结果以及断点开始(待完善)
y以上每个功能模块单独由一个文件完成,整个结构分为7个文件
main.lua opt.lua dataloder.lua model.lua train.lua test.lua checkpont.lua(待完善)
require 'torch' require 'nn' require 'optim' local DataLoder = require 'dataloder' --load the dataloder.lua local opts = require 'opt' local Model = require 'model' local Test = require 'test' local checkpoints = require 'checkpoint' local Trainer = require 'train' torch.setdefaulttensortype = ('torch.FloatTensor') -- torch.setnumthreads(1) torch.manualSeed(opt.manualSeed) cutorch.manualSeedAll(opt.manualSeed) local opt = opts.parse(arg) --load the options local trainset,testset = DataLoder.creat(opt) --load the dataset local model,criterion = Model.setup(opt) --load the model,criterion if(opt.type == 'cuda') then --turn on gpu:model-criterion-data-label model = model:cuda() criterion = criterion:cuda() trainset.data = trainset.data:cuda() trainset.label = trainset.label:cuda() testset.data = testset.data:cuda() testset.label = testset.label:cuda() end function trainset:size() --prepare for training return self.data:size(1) end local trainer = Trainer(model,criterion,opt) bestModel = false for epoch = 1,opt.max_epoch do local current_error = trainer:train(epoch,trainset) --save the current station --checkpoints.save(epoch, model, trainer.optimState, bestModel, opt) end local correct_rate = Test.run(opt,testset,model) print(correct_rate)
运行程序时,直接在文件所在目录终端执行:th main.lua 即可运行程序。若需改变options,例如gpu运行:th main.lua –type cuda
相关文章推荐
- caffe神经网络框架的辅助工具(将图片转换为leveldb格式)
- python keras (一个超好用的神经网络框架)的使用以及实例
- 【R笔记】基于R构建tensorflow框架实现神经网络
- TensorFire:WEB端的高性能神经网络框架
- python keras 神经网络框架 的使用以及实例
- 基于RBF的概率神经网络框架
- Joone框架的神经网络如何保存和载入训练好的模型
- 【深度学习笔记002 神经网络与主流框架】
- 物体检测算法全概述:从传统检测方法到深度神经网络框架
- 资讯精选 |【深度学习框架大PK】褚晓文教授:五大深度学习框架三类神经网络全面测评(23PPT)
- Java神经网络的框架Neuroph 2.5 with Neuroph Studio 测试
- C#人工智能(AI)编程:对神经网络面向一个基本的对象(OOP)框架
- 【神经网络与深度学习】Caffe使用step by step:caffe框架下的基本操作和分析
- 深度学习笔记——深度学习框架TensorFlow之DNN深度神经网络的实现(十四)
- Caffe(卷积神经网络框架)介绍
- 深度神经网络DNN的多GPU数据并行框架 及其在语音识别的应用
- Java神经网络的框架Neuroph 2.5 with Neuroph Studio 测试
- 神经网络开源框架及学习资源
- 基于多尺度卷积神经网络框架结合语义标签和surface normals以及深度预测
- 第2次课改善深层神经网络:超参数优化、正则化以及优化 - week3 超参数调试、Batch正则化和程序框架