You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running into an IndexError problem when using the evaluate_generative_model function.
To give you a better picture of what am I doing, I am using hyperopt to optimize the hyperparameters eta and gamma from the function evaluate_generative_model, and the parameter space for each is [-10, 10] in steps of 0.1, so for each trial, it selects two values from this space and send them to the function. Here is my code:
# Define the hyperparameters space
gamma = np.r_[-10:10:0.1]
eta = np.r_[-10:10:0.1]
hp_space = {
'gamma': hp.choice('gamma', gamma),
'eta': hp.choice('eta', eta)
}
# Setting up the number of evaluations and Trials object
n_evals = 2000
trials = Trials()
# Running the optimization
res_gnm = fmin(
lambda hps: bct.evaluate_generative_model(seed_network,
target_network,
mean_dist,
[hps['eta']],
gamma=[hps['gamma']],
model_type='matching')[0],
space=hp_space, algo=tpe.suggest, trials=trials, max_evals=n_evals,
rstate=np.random.RandomState(42)
)
Apparently, this problem disappears if I add this to the generative.py code (line 327)
...
for ii in range(mseed, m):
C = np.append(0, np.cumsum(Ff[u,v]))
r_n = np.sum(np.random.random()*C[-1] >= C) #storing the original index
r = r_n - 1 #subtracting 1 from it
uu = u[r]
vv = v[r]
A[uu,vv] = A[vv,uu] = 1
...
which is basically subtracting one from the index (I was assuming that it could be a 0-indexing problem, since the original code came from a matlab toolbox).
Even with this fix, though, the same error occurs when I use the evaluate_generative_model function passing eta and gamma as vectors. gnm_eval = bct.evaluate_generative_model(seed_network, sc_dataset[0]['weights_bu'], mean_dist, eta, gamma=gamma)
Is there anything that I am doing wrong when using this function?
Greetings,
I am running into an IndexError problem when using the evaluate_generative_model function.
To give you a better picture of what am I doing, I am using hyperopt to optimize the hyperparameters eta and gamma from the function evaluate_generative_model, and the parameter space for each is [-10, 10] in steps of 0.1, so for each trial, it selects two values from this space and send them to the function. Here is my code:
Apparently, this problem disappears if I add this to the generative.py code (line 327)
which is basically subtracting one from the index (I was assuming that it could be a 0-indexing problem, since the original code came from a matlab toolbox).
Even with this fix, though, the same error occurs when I use the evaluate_generative_model function passing eta and gamma as vectors.
gnm_eval = bct.evaluate_generative_model(seed_network, sc_dataset[0]['weights_bu'], mean_dist, eta, gamma=gamma)
Is there anything that I am doing wrong when using this function?
Thank you for your help.
P.S: I am attaching the dist, seed and target matrices as numpy files.
dist.txt
seed.txt
target.txt
The text was updated successfully, but these errors were encountered: