I want to evaluate and get the loss of each sample. So I want to apply multiprocessing to accelerate it. But it shows error "The Session graph is empty. Add operations to the graph before calling run()."
model.fit(x=X_measured, y=y_train, batch_size=batch_size, epochs=epochs, verbose=0,
validation_data=(X_measured_test,y_test), shuffle=True)
def get_loss(i, model, X_measured, y_train):
samples_loss=model.evaluate(x=X_measured[i:i+1,:],y=y_train[i:i+1,:],batch_size=None,verbose=0,steps=1)
return samples_loss
pool = mp.Pool(mp.cpu_count())
samples_loss=pool.starmap(get_loss, [(j, model, X_measured, y_train) for j in range(X_measured.shape[0])])
pool.close()