theano

theano: gradient where cost is imag(x)

泪湿孤枕 提交于 2019-12-24 03:59:49
问题 If I have a cost that is the imaginary part of a complex number, trying to obtain the gradient with theano I get the following error: TypeError: Elemwise{imag,no_inplace}.grad illegally returned an integer-valued variable. (Input index 0, dtype complex128) Is it not possible to use the imaginary part as cost despite it being a real-valued cost? Edit. Minimal working example import theano.tensor as T from theano import function a = T.zscalar('a') f = function([a], T.grad(T.imag(a),a)) I would

How to keep the weight value to zero in a particular location using theano or lasagne?

心不动则不痛 提交于 2019-12-24 01:37:08
问题 I'm a theano and lasagne user. I have a problem dealing with the variable length of the input matrix. i.e) x1 = [0, 1, 3] x2 = [1, 2] matrix_embedding = [ [ 0.1, 0.2, 0.3], [ 0.4, 0.5, 0.6], [ 0.2, 0.3, 0.5], [ 0.5, 0.6, 0.7], ] matrix_embedding[x1] = [ [ 0.1, 0.2, 0.3], [ 0.4, 0.5, 0.6], [ 0.5, 0.6, 0.7] ] matrix_embedding[x2] = [ [ 0.4, 0.5, 0.6], [ 0.2, 0.3, 0.5], ] So, I try to use the padding. matrix_padding_embedding = [ [ 0.1, 0.2, 0.3], [ 0.4, 0.5, 0.6], [ 0.2, 0.3, 0.5], [ 0.5, 0.6,

Lasagne dropoutlayer does not utilize GPU efficiently

寵の児 提交于 2019-12-24 00:37:13
问题 I am using theano and lasagne for a DNN speech enhancement project. I use a feed-forward network very similar to the mnist example in the lasagne documentation (/github.com/Lasagne/Lasagne/blob/master/examples/mnist.py). This network uses several dropout layers. I train my network on an Nvidia Titan X GPU. However, when I do not use dropout my GPU utilization is approximately 60% and one epoch takes around 60s but when I use dropout my GPU utilization drops to 8% and each epoch takes

Dirichlet process in PyMC 3

偶尔善良 提交于 2019-12-24 00:20:49
问题 I would like to implement to implement the Dirichlet process example referenced in Implementing Dirichlet processes for Bayesian semi-parametric models (source: here) in PyMC 3. In the example the stick-breaking probabilities are computed using the pymc.deterministic decorator: v = pymc.Beta('v', alpha=1, beta=alpha, size=N_dp) @pymc.deterministic def p(v=v): """ Calculate Dirichlet probabilities """ # Probabilities from betas value = [u*np.prod(1-v[:i]) for i,u in enumerate(v)] # Enforce sum

ERROR (theano.gof.opt): Optimization failure due to: constant_folding

為{幸葍}努か 提交于 2019-12-23 22:37:32
问题 In Neural Networks and Deep Learning, there's an object called network3 (which is a PY file, written for python 2.7 and theano 0.7). I modified it to run with python 3.6 and theano 1.0.3. However, when I run the following code: import network3 from network3 import Network from network3 import ConvPoolLayer , FullyConnectedLayer , SoftmaxLayer training_data , validation_data , test_data = network3.load_data_shared() mini_batch_size = 10 net = Network([FullyConnectedLayer(n_in=784, n_out=100),

Finding the right parameters for neural network for pong-game

大兔子大兔子 提交于 2019-12-23 19:57:06
问题 I have some trouble with my implementation of a deep neural network to the game Pong because my network is always diverging, regardless which parameters I change. I took a Pong-Game and implemented a theano/lasagne based deep-q learning algorithm which is based on the famous nature paper by Googles Deepmind. What I want: Instead of feeding the network with pixel data I want to input the x- and y-position of the ball and the y-position of the paddle for 4 consecutive frames. So I got a total

How to force Theano to parallelize an operation on GPU (test case: numpy.bincount)

半城伤御伤魂 提交于 2019-12-23 17:47:10
问题 I am looking for possibility to speed up computation of bincount using GPU. Reference code in numpy: x_new = numpy.random.randint(0, 1000, 1000000) %timeit numpy.bincount(x_new) 100 loops, best of 3: 2.33 ms per loop I want to measure only speed of operation, not the time spent on passing array, so I create a shared variable: x = theano.shared(numpy.random.randint(0, 1000, 1000000)) theano_bincount = theano.function([], T.extra_ops.bincount(x)) This operation is of course highly

Should I substract imagenet pretrained inception_v3 model mean value at inception_v3.py keras?

梦想的初衷 提交于 2019-12-23 17:06:30
问题 def preprocess_input(x): x /= 255. x -= 0.5 x *= 2. return x  I am using keras inception_v3 imagenet pretrained model(inception_v3.py) to finetune on my own dataset.  When I want to subtract the imagenet mean value [123.68, 116.779, 103.939] and reverse axis RGB to BGR as we often do, I find that the author provided a _preprocess_input()_ function at the end.I am confused about this.   Should I use the provided function preprocess_input() or subtract mean value and reverse axis as usual?  

Optimizing Keras to use all available CPU resources

余生长醉 提交于 2019-12-23 15:44:40
问题 Ok, I don't really know what I'm talking about here so bear with me. I am running Keras with Theano backend to run a basic neural net (just a tutorial set up for now) on MNIST images. In the past, I have been using my old HP laptop because I have a dual boot setup with Windows and Ubuntu 16.06. I am trying to replace this laptop so I can retire it and use my new(er) Sony laptop. I set up the same dual boot with Ubuntu 16.06 and Windows 10. Here is the issue: When I run it on my old HP (Ubuntu

Python的发展前景及干货、值得知道的Python程序库

天涯浪子 提交于 2019-12-23 15:36:30
如今,Python已经成为一种再主流不过的编程语言了。 它天生丽质,易于读写,非常实用,从而赢得广泛的群众基础,被誉为“宇宙最好的编程语言”,被无数程序员热烈追捧。 随着时代的发展越来越快,市场需求越来越大,Python的应用也越来越广泛,不论你是刚开始学习Python的小白还是已经接触了Python,我都希望这篇文章能对你们有所帮助。 根据 Stack Overflow 流量统计,2017 年 6 月,Python 第一次成为高收入国家 Stack Overflow 访问量最大的标签,照此发展,到了 2019 年,Python 肯定会成为最受欢迎的标签。 在 GitHub 年度报告中,Python 超越 Java 成第二受欢迎语言。所有这些“刷榜”,都离不开最近人工智能尤其是机器学习的火热。Python 被誉为最好人工智能的语言,因为: 在数据科学和 AI 中占据主导地位; 拥有优质的文档和丰富的库,对于科学用途的广泛编程任务都很有用; 设计非常好,快速,坚固,可移植,可扩展; 开源,而且拥有一个健康、活跃、支持度高的社区。 Python是一门新手友好、功能强大、高效灵活的编程语言,学会之后无论是想进入数据分析、人工智能、网站开发这些领域,还是希望掌握第一门编程语言,都可以用Python来开启未来无限可能! 值得知道的Python程序库 Scikit-learn