python - mapping a numpy array to a function, passing along the indices -


i have trained per-pixel models on many images , want evaluate them on new images.

what i'd each image of shape (n, m, 3), apply function in fashion:

myfunc(array[i, j, :], i, j)  # takes (3,1) input , indices def myfunc(input, i, j):   ret1, ret2 = model[i,j].predict(input)   # returns single float value  return ret1[1]  

where i, j indices, myfunc correct model parameters apply. if helps, model can numpy array of objects, same dimensions original input's first 2 dimensions (n, m)

i looking @ ufuncs , vectorize , wasn't sure if did wanted. there provided interface doing this, or have loop through array myself (ugly , possibly slower in python).

alternatively, applying same function each value?

e.g.

myfunc(array[i, j, :])  # takes (3,1) input def myfunc(input):   ret1, ret2 = model.predict(input)   # returns single float value  return ret1[1]  


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -