(learner, X, n_instances=1, T=100)
| 55 | """ |
| 56 | |
| 57 | def max_entropy(learner, X, n_instances=1, T=100): |
| 58 | random_subset = np.random.choice(X.shape[0], 2000, replace=False) |
| 59 | MC_output = K.function([learner.estimator.model.layers[0].input, K.learning_phase()], |
| 60 | [learner.estimator.model.layers[-1].output]) |
| 61 | learning_phase = True |
| 62 | MC_samples = [MC_output([X[random_subset], learning_phase])[0] for _ in range(T)] |
| 63 | MC_samples = np.array(MC_samples) # [#samples x batch size x #classes] |
| 64 | expected_p = np.mean(MC_samples, axis=0) |
| 65 | acquisition = - np.sum(expected_p * np.log(expected_p + 1e-10), axis=-1) # [batch size] |
| 66 | idx = (-acquisition).argsort()[:n_instances] |
| 67 | return random_subset[idx] |
| 68 | |
| 69 | def uniform(learner, X, n_instances=1): |
| 70 | return np.random.choice(range(len(X)), size=n_instances, replace=False) |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…