folgender Quellcode funktioniert einwandfrei:
Code: Alles auswählen
import numpy
def fep(x):
""" some function """
y = numpy.zeros(3)
pos = numpy.array([0,1,2])
y[pos] = x[pos] + 1
return y
x_array = numpy.array([3,4,5])
print(fep(x_array))
Code: Alles auswählen
def fun(x):
""" some function """
y = numpy.zeros(3)
pos = numpy.array([0,1,2])
y[pos] = x[pos] + 1
return y
# forward mode without building the computational graph
# -----------------------------------------------------
x = UTPM.init_jacobian(numpy.array([3,4,5]))
y = fun(x)
algopy_jacobian = UTPM.extract_jacobian(y)
print 'jacobian = ', algopy_jacobian
Code: Alles auswählen
y[pos] = x[pos] +1
File "C:\Python26\lib\site-packages\algopy\utpm\utpm.py", line 70 in__getitem__ if isinstance(sl, int) or sl == Ellipsis or isinstance(sl, slice): ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()