python +numpy,theano,cifar 2
来源:互联网 发布:win10系统开机优化 编辑:程序博客网 时间:2024/05/22 00:12
数据要归一化到[0..1)
貌似dbn还是很普通。cnn提供了共享权值,局部感受野,dbn提供了基于层的学习和非监督学习,模拟了人类的学习,我们可以不知道一个事情是啥,当看多了,以后一点就通了。
有把cnn和dbn结合起来的。
如果把cnn和dbn结合,是在第一层实现cnn,还是每个层都用相同的cnn呢?
dbn的各层,是否可用不同的rmb?
对于shared variable 的一点理解,主要的说明在注释中了。另外,也想过是否直接通过inputs传数据,对于多个函数共用一个数据的情况,似乎不行,还是要用共享变量的。
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 29 18:30:54 2011
@author: Administrator
"""
import numpy,theano,theano.tensor as T
#define model
idx=T.lscalar('idx')
x=T.vector('x')
y=T.vector('y')
f1=T.sum(x)
fn1=theano.function([x],f1)
#prepare data
a=[1,2,3,4,5]
b=[6,7,8,9,10]
a_n=numpy.asarray(a,dtype=theano.config.floatX)
b_n=numpy.asarray(a,dtype=theano.config.floatX)
a_s=theano.shared(a_n)
b_s=theano.shared(b_n)
#run the operations defined by theano.function
print fn1(a)#works
print fn1(a_n)#works
# theano function works with tensor ,not shared variable
# we can't use share variable as parameters
#fn2=theano.function([idx],outputs=f1,givens={x:a_s})#not works,a_s is a shared\
# variable,we should tansfermate it to a tensor by a_s[...]?
fn2=theano.function([idx],outputs=f1,givens={x:a_s[0:idx]})
print fn2(3)
a_s=b_s #这条语句造成了后面fn2(3)=6,实际上,这里把a_s指向了b_s.
print fn2(3) #,we can't change shared variable by point it to other shared variable
#there are three variables,symbol variable,system variable,shared variable
#symbol variable is just used in write theano function.
#sysem variable is point to a data area
# so does shared variable,while shared variable is managed by theano,not system
#a theano function is combined with shared variable when this fucntion is compiled
a_s.set_value(b)
print fn2(3)
print a_s.get_value()
output:
15.0
15.0
6.0
6.0
6.0
[ 6. 7. 8. 9. 10.]
通过shard variable 可以减少数据交换,要改变shared variable 的值,可以通过set_value。
set_value(b) 时需要把b先转换成numpy.array,你不做。theano也会这么做。容易出错,不如自己来做。
尤其是在borrow=true时。
关于borrow=true,本来是很好立即的。偏偏有些细节不太明白。基本上cpu上,还是用borrow=true,gpu上用deepcopy(borrow=false)
- python +numpy,theano,cifar 2
- python +numpy,theano,cifar
- 循环神经网络教程2-用Python、numpy和Theano实现RNNPart 2 – Implementing a RNN with Python, Numpy and Theano
- Recurrent Neural Networks Tutorial, Part 2 – Implementing a RNN with Python, Numpy and Theano
- Python配置第三方库numpy、scipy、theano
- 循环神经网络在Python 、Numpy和Theano中的实现
- numpy,theano中的函数
- theano,numpy和scipy
- Theano学习二----numpy
- 【Theano】复习Numpy
- Numpy and Theano broadcasting
- theano,numpy tile函数
- Theano 中文文档 0.9 - 7.1.2 NumPy新手
- Theano 学习numpy.asarray(), theano.shared()
- python numpy 基础2
- python-numpy小结2
- windows64 配置numpy,scipy,theano
- Python数值计算工具包numpy,scipy,theano等的安装--Anaconda
- 二叉查找树范围查询算法
- g2 t-mobile大内存 3.5mm spl, radio 不能用一般的升级工具 升
- 单链表逆置(C++)
- Windows的窗口类风格、鼠标光标风格
- 【爱生活】关元穴能有效调理身体
- python +numpy,theano,cifar 2
- 嵌入式根文件系统制作中几个重要文件详解
- 多线程的那点儿事(之原子锁)
- 淘宝蝌蚪的SVN免费对外开放了
- JNI初步学习
- vxworks下格式化flash
- 【POJ】1001 Exponentiation
- Repeater
- Java IO 实现简单文件读与写