farizrahman4u / seq2seq

Sequence to Sequence Learning with Keras
GNU General Public License v2.0
3.17k stars 846 forks source link

IndexError: index 3 is out of bounds for axis 0 with size 3 #277

Closed arnabnaskar95 closed 4 years ago

arnabnaskar95 commented 4 years ago

I want to get 3 parameters from the given equation. hence i want to optimize it. But after executing the code i am getting error : "IndexError: index 3 is out of bounds for axis 0 with size 3" and the traceback is coming from the --------> minimize.(fnz,..... ) any clue where can i correct it?

import numpy as np import math import pandas as pd from scipy.optimize import minimize import math TTF =[50,94, 196, 268, 290, 329, 332, 347, 544, 732, 811, 899, 945, 950, 955, 991 ,1013 ,1152 ,1362 ,1459 ,1489 ,1512 ,1525 ,1539] Repair = pd.DataFrame(TTF, columns = ["TTF"]) for i in range(0,len(Repair["TTF"])-2): T[i+1] = Repair["TTF"][i+1] - Repair["TTF"][i] T[0] = Repair["TTF"][0]

def Vir(temp):

V1 = np.ones(23)
V1[0] = T[0]*temp
for i in range(1,(len(T))):
    V1[i]=(temp*(T[i]+V1[i-1]))

return(V1)

theta =np.array([[0.003],[0.03],[0.4]]) def fnz(theta):

X = max(TTF)
n = len(TTF)
big_data = (Vir(theta[0]))
return -((n*(math.log(theta[1])+math.log(theta[2])))- theta[1] * (((1539 - X + 
            (big_data[-1]+T[-1])*theta[3] )^ theta[2])
         - (((big_data[-1])+(T[-1]))*theta[3]) ^ theta[2]) - 
          theta[1] * sum(( T +big_data )^ theta[2] - (big_data^ theta[2]))+
          (theta[2]-1)* sum(math.log(T+big_data)))

x0 = np.array([theta[0],theta[1],theta[2]] bnds = ((0.0000001, 1), (0.000001, 5),(0.0001,1)) results = minimize(fnz, x0, method='SLSQP', bounds = bnds)

arnabnaskar95 commented 4 years ago

solved