Created
February 1, 2020 16:17
-
-
Save CVxTz/631dee73c4b3cfd4ce9a467f49b93d75 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i, step_size in enumerate(step_sizes): | |
X_used = X[used_samples, ...] | |
Y_used = Y[used_samples, ...] | |
X_unused = X[unused_samples, ...] | |
Y_unused = Y[unused_samples, ...] | |
model = get_model() | |
model.fit(X_used, Y_used, epochs=45, verbose=1, batch_size=32) | |
pred_ununsed = model.predict(X_unused).tolist() | |
entr = [entropy(l) for l in pred_ununsed] | |
threshold = sorted(entr, reverse=True)[step_size] | |
pred_test = model.predict(X_test) | |
pred_test = np.argmax(pred_test, axis=-1) | |
f1 = f1_score(Y_test, pred_test, average="macro") | |
acc = accuracy_score(Y_test, pred_test) | |
results.append({"size": X_used.shape[0], "accuracy": acc, "f1": f1}) | |
step = [x for x, v in zip(unused_samples, entr) if v >= threshold] | |
used_samples += step | |
unused_samples = list(set(unused_samples) - set(step)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment