1、Lasagne简单介绍

lasagne意味千层饼,是基于theano之上主要用于建立和训练神经网络的深度学习库。Lasagne is a lightweight library to build and train neural networks in Theano.

网站链接:https://github.com/Lasagne/Lasagne、     lasagne官网教程

主要特点有:

(1)支持所有的前馈神经网络的模型,包括CNNs、RNN+LSTM以及任何扩展的卷积神经网络。

Supports feed-forward networks such as Convolutional Neural Networks (CNNs), recurrent networks including Long Short-Term Memory (LSTM), and any combination thereof

(2)支持多输入和多输出的网络框架、包括额外附加的分类器

Allows architectures of multiple inputs and multiple outputs, including auxiliary classifiers

(3)拥有多种训练的梯度优化算法。Nesterov momentum, RMSprop and ADAM

(4) 继承theano的优点,它拥有theano的所有常见的损失函数以及无需自行计算梯度。

Freely definable cost function and no need to derive gradients due to Theano's symbolic differentiation

(5)通过设置脚本的配置文件,支持CPUs和GPUs之间运行的转换。

Transparent support of CPUs and GPUs due to Theano's expression compiler

设计的目的:

(1)简易性:易于使用和扩展的机器学习库Be easy to use, easy to understand and easy to extend, to facilitate use in research

(2)透明性: Do not hide Theano behind abstractions, directly process and return Theano expressions or Python / numpy data types

(3)模块化: Allow all parts (layers, regularizers, optimizers, ...) to be used independently of Lasagne(4)实用性(Pragmatism): Make common use cases easy, do not overrate uncommon cases

(5)限制Restraint: Do not obstruct(阻塞) users with features they decide not to use

(6)集中性: "Do one thing and do it well"

2、lasagne的安装(ubuntu14.04下)

(1)预备知识 prerequisites:theano库 theano installation,注意:theano安装的版本取决于lasagne安装的版本。

(2)Stable Lasagne release:lasagne 0.1版本需要匹配最近的theano版本,可执行以下代码来获取相应的版本。

sudo pip install -r https://raw.githubusercontent.com/Lasagne/Lasagne/v0.1/requirements.txt

为了简洁方面,也可以同时安装theano和lasagne。

sudo pip install --upgrade https://github.com/Theano/Theano/archive/master.zip 
sudo pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip

developed install:也可以直接克隆lasagne库

git clone https://github.com/Lasagne/Lasagne.git

至此,给出lasagne大体的框架:(需要自己加载训练数据才能运行出结果)

import lasagne
import theano
import theano.tensor as T# create Theano variables for input and target minibatch
input_var = T.tensor4('X')
target_var = T.ivector('y')# create a small convolutional neural network
from lasagne.nonlinearities import leaky_rectify, softmax
network = lasagne.layers.InputLayer((None, 3, 32, 32), input_var)
network = lasagne.layers.Conv2DLayer(network, 64, (3, 3),nonlinearity=leaky_rectify)
network = lasagne.layers.Conv2DLayer(network, 32, (3, 3),nonlinearity=leaky_rectify)
network = lasagne.layers.Pool2DLayer(network, (3, 3), stride=2, mode='max')
network = lasagne.layers.DenseLayer(lasagne.layers.dropout(network, 0.5),128, nonlinearity=leaky_rectify,W=lasagne.init.Orthogonal())network = lasagne.layers.DenseLayer(lasagne.layers.dropout(network, 0.5),10, nonlinearity=softmax)# create loss function
prediction = lasagne.layers.get_output(network)
loss = lasagne.objectives.categorical_crossentropy(prediction, target_var)
loss = loss.mean() + 1e-4 * lasagne.regularization.regularize_network_params(network, lasagne.regularization.l2)
# create parameter update expressions
params = lasagne.layers.get_all_params(network, trainable=True)
updates = lasagne.updates.nesterov_momentum(loss, params, learning_rate=0.01,momentum=0.9)
# compile training function that updates parameters and returns training loss
train_fn = theano.function([input_var, target_var], loss, updates=updates)# train network (assuming you've got some training data in numpy arrays)
for epoch in range(100):loss = 0for input_batch, target_batch in training_data:
loss += train_fn(input_batch, target_batch)print("Epoch %d: Loss %g" % (epoch + 1, loss / len(training_data)))# use trained network for predictions
test_prediction = lasagne.layers.get_output(network, deterministic=True)
predict_fn = theano.function([input_var], T.argmax(test_prediction, axis=1))
print("Predicted class for first test input: %r" % predict_fn(test_data[0]))

3、配置GPU

GPU的配置需要cuda支持的英伟达显卡,(  NVIDIA GPU with CUDA),查看电脑配置的显卡型号,下载对应的所支持的cuda版本

https://developer.nvidia.com/cuda-downloads放在主目录下。

(1)按照cuda官网教程完成安装。

(2)添加环境变量

执行sudo gedit  ~/.bashrc 打开.bashrc文件,在末尾写入以下几行:

  1. export CUDA_HOME=/usr/local/cuda-***/bin   #****代表cuda对应的版本,cuda-7.0或cuda-7.5、cuda8.0等
  2. export LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64  #如果是32位,去掉末尾的64

执行 sudo source ~/.bashrc    #使环境变量生效

检查环境变量:echo $PATH

在home目录下配置.theanorc文件

[global]
floatX = float32
device = gpu

如果cuda配置成功,终端执行python,在python下,import theano 则会显示print下的结果

THEANO_FLAGS=device=gpu python -c "import theano; print(theano.sandbox.cuda.device_properties(0))"

Theano深度学习框架之Lasagne安装及入门相关推荐

  1. 深度学习框架Keras的安装

    原文链接:https://blog.csdn.net/qingzhuochenfu/article/details/51187603 本人已经将最新博客更新转移至个人网站了,欢迎来访~~ SCP-17 ...

  2. [PyTroch系列-1]:PyTroch深度学习框架的详细安装过程

    作者主页(文火冰糖的硅基工坊):文火冰糖(王文兵)的博客_文火冰糖的硅基工坊_CSDN博客 本文网址:[PyTroch系列-1]:PyTroch深度学习框架的详细安装过程_文火冰糖(王文兵)的博客-C ...

  3. yolo专属深度学习框架darknet的安装记录

    darknet是yolo算法的作者Joseph Redmon使用c语言编写的一个开源卷积神经网络训练框架 如果项目中用到了yolo卷积神经网络模型,darknet框架是你的不二之选 darknet项目 ...

  4. TVM:深度学习框架编译器的安装踩坑集

    目录 一.引言 二.流程 三.踩坑 四.备注 一.引言 4月底的时候,花了一天时间安装TVM这个东西.那时,上来就弄TVM 0.8的版本,但因为具体安装的流程不是很懂,所以出现了一些莫名其妙的问题.后 ...

  5. Tensorflow【实战Google深度学习框架】—完整的TensorFlow入门教程

    目录 1.介绍 2.导入 3.The Computational Graph 4.TensorBoard 5.张量(Tensor) 6.数据流图(Dataflow Graph) 7.Sesssion ...

  6. 深度学习入门笔记系列(一)——深度学习框架 tensorflow 的介绍与安装

    本系列将分为 8 篇 .今天是第一篇 ,工欲善其事必先利其器 ,先简单讲讲当前的主流深度学习框架 TensorFlow 及其安装方法 . 我们知道 ,深度学习研究的热潮持续高涨 ,许多的开源深度学习框 ...

  7. CV:Win10下深度学习框架安装之Tensorflow/tensorflow_gpu+Cuda+Cudnn(最清楚/最快捷)之详细攻略(图文教程)

    CV:Win10下深度学习框架安装之Tensorflow/tensorflow_gpu+Cuda+Cudnn(最清楚/最快捷)之详细攻略(图文教程) 导读 本人在Win10下安装深度学习框架Tenso ...

  8. DL框架之DL4J/Deeplearning4j:深度学习框架DL4J/Deeplearning4j的简介、安装、使用方法之详细攻略

    DL框架之DL4J/Deeplearning4j:深度学习框架DL4J/Deeplearning4j的简介.安装.使用方法之详细攻略 目录 深度学习框架Deeplearning4j的简介 1.Deep ...

  9. 8种主流深度学习框架介绍

    导读:近几年随着深度学习算法的发展,出现了许多深度学习框架.这些框架各有所长,各具特色.常用的开源框架有TensorFlow.Keras.Caffe.PyTorch.Theano.CNTK.MXNet ...

最新文章

  1. 请妥善保管自己的QQ等网络帐号
  2. ICS—CERT官网公示匡恩网络新发现四工控漏洞
  3. java如果把字符串转成对象_Java中的重复对象:不仅仅是字符串
  4. Weex组件库-Dialog
  5. H5如何实现唤起APP
  6. php 威盾加密解密,解析php加密解密混淆的手段,如 phpjm,phpdp神盾,php威盾
  7. 新浪微博开放平台开发步骤简介(适合新手看)
  8. 浅谈:企业需要什么样的技术总监?技术总监需要具备什么能力?
  9. 0089-【生物软件】-ANNOVAR基因变异注释
  10. 外贸企业邮箱是什么?大连邮箱,邮件归档系统
  11. 【刘文彬】【源码解读】EOS测试插件:txn_test_gen_plugin.cpp
  12. linux wifi6,WIFI6 基本知识(一)
  13. 尚学堂-HTML-CSS(基础)的学习记录
  14. 600 岁的故宫,也上了人工智能的车
  15. 鼠标使用板载内存和使用计算机上,【罗技G700s无线鼠标使用总结】功能|配置|模式|灵敏度_摘要频道_什么值得买...
  16. 计算机一级上机考试证书,大学生考证不要盲目跟风,这几个证书”含金量低“,不值得考...
  17. 小程序商城制作一个需要多少钱?一般包括哪些费用?
  18. 深度学习100例-卷积神经网络(VGG-16)识别海贼王草帽一伙 | 第6天
  19. 单调递增最长子序列 拦截导弹(nyoj 17 nyoj 79)
  20. 大学生如何寻找实习机会

热门文章

  1. Cache Maintenance-通过set/way对cache进行clean和invalidate操作-汇编代码详解
  2. UC浏览器梁延俊:移动浏览器HTML5之路
  3. sqlserver作为目标端在不安装hvr的情形下同步Location设置
  4. android项目之山寨天天动听 — 前言
  5. 酷我音乐区块链教程_酷我音乐入局区块链 推出音乐挖矿
  6. ubuntu 12.04 安装openldap(不开启加密验证)
  7. arcGis 加载地图
  8. ant+dva Ract系统前端开发教程
  9. 关于vue的url请求图片的问题,请求失败
  10. 【2022研电赛】兆易创新杯全国二等奖:自动驾驶汽车路面目标智能检测系统