theano

Keras model.summary() result - Understanding the # of Parameters

為{幸葍}努か 提交于 2019-12-03 00:55:07
问题 I have a simple NN model for detecting hand-written digits from a 28x28px image written in python using Keras (Theano backend): model0 = Sequential() #number of epochs to train for nb_epoch = 12 #amount of data each iteration in an epoch sees batch_size = 128 model0.add(Flatten(input_shape=(1, img_rows, img_cols))) model0.add(Dense(nb_classes)) model0.add(Activation('softmax')) model0.compile(loss='categorical_crossentropy', optimizer='sgd', metrics=['accuracy']) model0.fit(X_train, Y_train,

Keras 切换后端(Theano和TensorFlow)

匿名 (未验证) 提交于 2019-12-03 00:36:02
中文文档的描述: keras中文文档,切换后端 其实就是在 C:\Users\Administrator (Administrator是我的windos用户名字,找你对应的用户名就行)下有个文件夹 .keras ,里面有 keras.json 文件,改一下里面的内容就好了,如果没有文件夹和文件,手动创建就行。 用theano的话,keras.json写入 { " image_dim_ordering ": "th" , " epsilon ": 1e-07 , " floatx ": "float32" , " backend ": "theano" } 用thesorflow的话,keras.json写入 { " image_dim_ordering ": "tf" , " epsilon ": 1e-07 , " floatx ": "float32" , " backend ": "tensorflow" } 最后保存就可以了 文章来源: Keras 切换后端(Theano和TensorFlow)

win10 解决WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

匿名 (未验证) 提交于 2019-12-03 00:26:01
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions. solution: cmd conda install mkl conda install mkl-servic conda install blas .theanorc.txt ldflags=-lmkl_rt 或者 ldflags=-lblas 文章来源: win10 解决WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

Ubuntu16.04+CUDA8.0+Theano-0.8安装教程

匿名 (未验证) 提交于 2019-12-03 00:18:01
Ubuntu16.04+CUDA8.0+Theano-0.8安装教程 Theano的安装真的是一部血泪史,花费了一个多星期的时间,终于在win7下和Ubuntu下安装theano成功,并且安装cuda、配置GPU工作。期间排了N多的坑,在这先说一下注意事项(避免各种坑): 如果选择在Windows下安装Theano,请参考另一篇博文:https://blog.csdn.net/hczhcz0905/article/details/80422169 操作系统:Ubuntu16.04LTS 步骤如下: (1):检查自己的显卡信息,检查GPU是否支持CUDA 终端输入:lspci | grip -iVGA 然后去cuda官网查看自己的GPU版本是否在CUDA 的支持列表中。 可以看到gcc版本高于5.0,由于cuda8.0版本以后已经支持了gcc高于5,如果选择安装cuda7.5或更低的话,需要降低gcc的版本。 (3)安装NVIDIA驱动,由于cuda自带的驱动可能无法定位内核信息,所以先安装驱动程序。 先卸载之前的驱动程序:$ sudo apt remove --purge nvidia* 添加Graphic Drivers PPA $ sudoadd-apt-repository ppa:graphics-drivers/ppa $ sudo apt-get update

转:theano使用GPU踩坑

匿名 (未验证) 提交于 2019-12-02 23:43:01
原文作者: lypbendlf 原文链接: https://www.cnblogs.com/BlueBlueSea/p/10778345.html 1.安装pygpu的部分 #使用豆瓣源or不使用,均安装失败 #报错: Looking in indexes: http://pypi.douban.com/simple/ Collecting pygpu No matching distribution found for pygpu #继续尝试使用conda,仍失败 conda install -c conda-forge pygpu` #报错: #尝试使用制定安装版本 pip install pygpu==0.7.5 #仍报错: Collecting pygpu==0.7.5 No matching distribution found for pygpu==0.7.5 //已保证pip是最新的。 #尝试将其拷贝到我的用户目录下 conda create -n my_root --clone="/data_d/public/miniconda2" #激活环境 source activate my_root #查看环境信息 #激活环境后再次尝试如下,仍旧失败 conda install pygpu #使用如下命令之后 sudo chown -R $USER:$USER ~/

Theano config directly in script

▼魔方 西西 提交于 2019-12-02 23:22:18
I'm new to Theano and I wonder how to configure the default setting directly from script (without setting envir. variables). E.g. this is a working solution ( source ): $ THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python check1.py I intend to come up with the identical solution that is executed by only: $ python check1.py and the additional parameters are set directly in the script itself. E.g. somehow like this: import theano theano.set('mode', 'FAST_RUN') theano.set('device', 'gpu') theano.set('floatX', 'float32') # rest of the script Is it even possible? I read the config page

Keras 获取中间某一层输出

匿名 (未验证) 提交于 2019-12-02 23:03:14
1.使用函数模型API,新建一个model,将输入和输出定义为原来的model的输入和想要的那一层的输出,然后重新进行predict. 1 #coding=utf-8 2 import seaborn as sbn 3 import pylab as plt 4 import theano 5 from keras.models import Sequential 6 from keras.layers import Dense,Activation 7 8 9 from keras.models import Model 10 11 model = Sequential() 12 model.add(Dense(32, activation='relu', input_dim=100)) 13 model.add(Dense(16, activation='relu',name="Dense_1")) 14 model.add(Dense(1, activation='sigmoid',name="Dense_2")) 15 model.compile(optimizer='rmsprop', 16 loss='binary_crossentropy', 17 metrics=['accuracy']) 18 19 # Generate dummy data 20 import

Converting Theano-based Keras model definition to TensorFlow

我怕爱的太早我们不能终老 提交于 2019-12-02 21:17:17
问题 When converting Theano-based Keras model definition to TensorFlow, is it enough to change the order of input_shape on the input layer? For example, the following layer Convolution2D(32, 3, 3, input_shape=(3, img_width, img_height)) will be replaced as Convolution2D(32, 3, 3, input_shape=(img_width, img_height, 3)) Note: I don't want to use dim_ordering='th' . 回答1: Answer from Francois Chollet: I think the question means "what input_shape should I pass to my first layer given that I'm using

How to put my dataset in a .pkl file in the exact format and data structure used in “mnist.pkl.gz”?

泄露秘密 提交于 2019-12-02 21:07:28
I'm trying to use the Theano library in python to do some experiments with Deep Belief Networks. I use the code in this address: DBN full code . This code use the MNIST Handwritten database . This file is already in pickle format. It is unpicked in: train_set valid_set test_set Which is further unpickled in: train_set_x, train_set_y = train_set valid_set_x, valid_set_y = valid_set test_set_x, test_set_y = test_set Please can someone give me the code that constructs this dataset in order to create my own? The DBN example I use needs the data in this format and I don't know how to do it. if

Using Python+Theano with OpenCL in an AMD GPU

不羁岁月 提交于 2019-12-02 20:47:42
I'm trying to use Python with Theano to accelerate some code with OpenCL. I installed libgpuarray and pygpu as instructed (I think), and got no errors. The installation detected the OpenCL runtime installed. I just cannot run the Theano example for OpenCL, mainly because I don't know how to specify my GPU. My GPU is a Radeon HD 5340/5450/5470 , according to inxi . All code in the Theano documentation uses device=cuda0 and the only place where OpenCL is mentioned, it says device=openclN where N is a number. I tried device=opencl0 and got a pygpu error saying that the correct format is opencl