I 'am trying to optimize a function which takes an input list of weights and change pixels of images with those weights and then calculates some Score (NSS Score) . Our target is to find the best input weights that give the highest NSS Score . For that we are using the Scipy minimize function
# Our input initial Weights , which we want to find the highest values of them
weights_init= [i for i in range(82)]
weights_init[0] = 0
min_result= minimize(global_stimuli_optimization,weights_init,method='L-BFGS-B', options={'disp': True})
The global_stimuli_optimization function takes the weights als input and make some processing and then calculate some Score (NSS)
def global_stimuli_optimization(weights):
... some attributs ...
for index,boundary in enumerate (boundaries):
... Some processing ...
all_stimuli = [all_stimuli_sorted for _,all_stimuli_sorted in sorted(zip(indices_sorted,all_stimuli_sorted))]
# we create a model
model = MySaliencyMapModel(all_stimuli)
# we calculate a score
nss_score = np.nanmean(model.NSSs(mit_stimuli, mit_fixations))
print('Weights : ',weights,' NSS :' , nss_score)
return - nss_score
The optimize functions works fine BUT performs only 1 iteration and then stops
Output :
* * *
Tit = total number of iterations
Tnf = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip = number of BFGS updates skippeds
Nact = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F = final function value
* * *
N Tit Tnf Tnint Skip Nact Projg F
82 0 1 0 0 0 0.000D+00 -6.932D-01
F = -0.693229780993317
CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL
Cauchy time 0.000E+00 seconds.
Subspace minimization time 0.000E+00 seconds.
Line search time 0.000E+00 seconds.
Total User time 0.000E+00 seconds.
Does anyone have an idea which it stops after the first iteration ?