theano

PyMC3 passing stochastic covariance matrix to pm.MvNormal()

落爺英雄遲暮 提交于 2021-02-10 16:47:45
问题 I've tried to fit a simple 2D gaussian model to observed data by using PyMC3. import numpy as np import pymc3 as pm n = 10000; np.random.seed(0) X = np.random.multivariate_normal([0,0], [[1,0],[0,1]], n); with pm.Model() as model: # PRIORS mu = [pm.Uniform('mux', lower=-1, upper=1), pm.Uniform('muy', lower=-1, upper=1)] cov = np.array([[pm.Uniform('a11', lower=0.1, upper=2), 0], [0, pm.Uniform('a22', lower=0.1, upper=2)]]) # LIKELIHOOD likelihood = pm.MvNormal('likelihood', mu=mu, cov=cov,

Keras isn't using Theano

霸气de小男生 提交于 2021-02-05 09:32:30
问题 1- I create a virtual env: mkvirtualenv kerasTH 2- I install keras using pip install keras 3- That's the output for pip list Package Version ------------- ------- h5py 2.10.0 joblib 0.16.0 Keras 2.4.3 numpy 1.19.1 Pillow 7.2.0 pip 20.2.2 PyYAML 5.3.1 scikit-learn 0.23.2 scipy 1.5.2 setuptools 49.6.0 six 1.15.0 Theano 1.0.5 threadpoolctl 2.1.0 wheel 0.35.1 When I run python and then import keras I get this error ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip

How can I change the backend of Keras dynamically?

半腔热情 提交于 2021-01-29 05:01:09
问题 Preliminary information: The answers given for the previously asked related questions (e.g., How to change the backend of Keras to Theano?, How to switch Backend with Keras (from TensorFlow to Theano)) did not work for me. Hence, I've created my own question. As the title clearly describes, I need to change the backend of Keras dynamically (per run). How can I do this? I'm using Python 3 . Here is a function that I've created through the feedback on the web: from keras import backend as K

One Hot Encoding giving same number for different words in keras

大憨熊 提交于 2021-01-28 18:15:31
问题 Why I am getting same results for different words? import keras keras.__version__ '1.0.0' import theano theano.__version__ '0.8.1' from keras.preprocessing.text import one_hot one_hot('START', 43) [26] one_hot('children', 43) [26] 回答1: unicity non-guaranteed in one hot encoding see one hot keras documentation 回答2: From the Keras source code, you can see that the words are hashed modulo the output dimension (43, in your case): def one_hot(text, n, filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n'

How to reuse computation graph for different inputs?

微笑、不失礼 提交于 2021-01-28 08:22:04
问题 I have my main flow of computation set up that I can train using train = theano.function(inputs=[x], outputs=[cost], updates=updates) Similarly, I have a function for predictions predict = theano.function(inputs=[x], outputs=[output]) Both of these functions accept the input x and send it through the same computation graph. I would now like to modify things so that when training, I can train using a noisy input, so I have something like input = get_corrupted_input(self.theano_rng, x, 0.5) at

Keras: Error when checking input

元气小坏坏 提交于 2021-01-28 06:36:51
问题 I am using Keras autoencodes with Theano backend. And want to make autoencode for 720x1080 RGB images. This is my code from keras.datasets import mnist import numpy as np from keras.layers import Input, LSTM, RepeatVector, Conv2D, MaxPooling2D, UpSampling2D from keras.models import Model from PIL import Image x_train = [] x_train_noisy = [] for i in range(5,1000): image = Image.open('data/trailerframes/frame' + str(i) + '.jpg', 'r') x_train.append(np.array(image)) image = Image.open('data

Debugging floating-point exception in python

戏子无情 提交于 2021-01-27 18:45:22
问题 I'm trying to run something that gives me a floating point exception ( Floating point exception. Core dumped . No traceback). Since that kind of exception can't be caught using usual try and except , I can't figure out what's causing the exception. Since I'm working on a VM, I'm not concerned about the implications of using fpectl . However, since I'm using anaconda python, I have no idea how to reinstall it with the appropriate flag. I tried downloading a python distribution from the

Theano sqrt returning NaN values

只愿长相守 提交于 2021-01-27 14:40:17
问题 In my code I'm using theano to calculate an euclidean distance matrix (code from here): import theano import theano.tensor as T MAT = T.fmatrix('MAT') squared_euclidean_distances = (MAT ** 2).sum(1).reshape((MAT.shape[0], 1)) + (MAT ** 2).sum(1).reshape((1, MAT.shape[0])) - 2 * MAT.dot(MAT.T) f_euclidean = theano.function([MAT], T.sqrt(squared_euclidean_distances)) def pdist_euclidean(mat): return f_euclidean(mat) But the following code causes some values of the matrix to be NaN . I've read

Share weights between two dense layers in keras

て烟熏妆下的殇ゞ 提交于 2021-01-20 18:20:52
问题 I have a code as follows. What I want to do is to share the same weights in two dense layers. The equation for op1 and op2 layer will be like that op1 = w1y1 + w2y2 + w3y3 + w4y4 + w5y5 + b1 op2 = w1z1 + w2z2 + w3z3 + w4z4 + w5z5 + b1 here w1 to w5 weights are shared between op1 and op2 layer inputs which are (y1 to y5) and (z1 to z5) respectively. ip_shape1 = Input(shape=(5,)) ip_shape2 = Input(shape=(5,)) op1 = Dense(1, activation = "sigmoid", kernel_initializer = "ones")(ip_shape1) op2 =

python十大机器学习框架

我只是一个虾纸丫 提交于 2021-01-08 17:30:11
随着人工智能技术的发展与普及,Python超越了许多其他编程语言,成为了机器学习领域中最热门最常用的编程语言之一。有许多原因致使Python在众多开发者中如此受追捧,其中之一便是其拥有大量的与机器学习相关的开源框架以及工具库。根据 http:// builtwith.com 的数据显示,45%的科技公司都倾向于使用Python作为人工智能与机器学习领域的编程语言。 使Python如此受欢迎主要由于: Python从设计之初就是为效率而生,以使项目从开发到部署再在运维都能保持较高的生产力; 坊间有大量的基于Python的开源框架及工具库; Python易于上手,可以说是编程小白的福音; 相比起C、Java、C++来讲,Python的语法更简单,更高级,只需要更少行数的代码便能实现其他编程语言同样的功能; Python的跨平台能力; 正是由于Python简单易用以及高开发效率,吸引了大量的开发者为其创建更多新的机器学习工具库;而又因为大量的机器学习工具库的出现,使得Python在机器学习领域变得如此流行。 下面我们就来探索一下机器学习领域中最受欢迎的十大框架或工具库: Tensorflow 如果你正在使用Python来从事机器学习项目,那么你一定听说过其中一个著名的框架——Tensorflow。Tensorflow框架主要由Google大脑团队开发,主要用于深度学习计算