UnboundLocalError: local variable 'e1' referenced before assignment

This small snippet does not raise any error for me

import numpy as np
import theano
import pymc3 as pm

n = 5
S = 2

A = np.random.randn(n, S)  # It's the same if I do  A = np.matrix(np.random.randn(n, S))
t = np.random.randn(n,)
tau = np.random.randn(S,)
t_change = np.random.randn(S,)

object_A = theano.shared(A, name='A')
object_t = theano.shared(t, name='t')
object_tau = theano.shared(tau, name='tau')

with pm.Model() as basic_model:
    k  = pm.Normal('k',mu=0,sd=5)
    m  = pm.Normal('m',mu=0,sd=5)    

    delta = pm.distributions.continuous.Laplace('delta',
                                                0,
                                                object_tau,
                                                shape=S)

    gamma = -object_t_change * delta
    Y =  (k + theano.dot(object_A,delta)) * object_t +( m + theano.dot(object_A, gamma))

I’m sorry but I can’t help. You have to try to get a minimal self contained working example that shows the error for us to be able to help. The snippet you provided does not raise any errors for me.

1 Like