Description of my problem:
This problem may sound silly, but I can’t fix it. Hope get your help. Thank you.
“k_s[0] = k
ValueError: setting an array element with a sequence.”
Description of my code:
object_t_change = theano.shared(t_change, name='t_change')
object_A = theano.shared(A, name='A')
object_X_new = theano.shared(X_new, name='X')
object_t = theano.shared(t, name='t')
object_y = theano.shared(y, name='y')
object_tau = theano.shared(tau, name='tau')
object_cap = theano.shared(cap, name='cap')
with pm.Model() as basic_model:
k = pm.Normal('k', mu=0, sd=5, testval=kinit[0])
m = pm.Normal('m', mu=0, sd=5, testval=kinit[1])
sigma_obs = pm.HalfNormal('sigma_obs', sd=0.5) # ~ normal(0, 0.5);
beta = pm.Normal('beta', mu=0, sd=sigmas[0], shape=K) # ~ normal(0, sigmas);
delta = pm.distributions.continuous.Laplace('delta', 0, object_tau,
shape=S) # delta ~ double_exponential(0, tau)
k_s = np.zeros(shape=S+1, dtype=np.float)
k_s[0] = k
for i in range(0, S, 1):
tmp = k_s[i] + delta[i]
k_s[i+1] = tmp
# Piecewise offsets
gamma = np.zeros(shape=S, dtype=np.float)
object_gamma = theano.shared(gamma, name='gamma')
m_pr = m # The offset in the previous segment
for i in range(0, S, 1):
object_gamma[i] = (object_t_change[i] - m_pr) * (1 - k_s[i] / k_s[i + 1])
m_pr = m_pr + object_gamma[i] # update for the next segment
tmp_ones = np.zeros(shape=T_time, dtype=np.float)
tmp1 = object_t - (m + T.dot(object_A, object_gamma_logistic))
tmp2 = T.exp(-(k + T.dot(object_A, delta)) * tmp1)
Y = object_cap / (tmp_ones + tmp2)