Commit 60016a16 authored by Oleh Astappiev's avatar Oleh Astappiev
Browse files

small fixes fo pickle dumps

parent e7123489
......@@ -19,11 +19,12 @@ load_weights_of(model, dataset)
emb_vectors, emb_labels = get_embeddings_of(model.get_embedding_model(), dataset)
emb_ds = SiameseModel.prepare_dataset(emb_vectors, emb_labels)
MARGIN = 0.5
siamese = SiameseModel(embedding_model=model.get_embedding_model(), image_vector_dimensions=512)
siamese.compile(loss_margin=0.05)
siamese.compile(loss_margin=MARGIN)
siamese.fit(emb_ds, num_classes=dataset.num_classes)
projection_vectors = siamese.projection_model.predict(emb_vectors)
save_vectors(projection_vectors, emb_labels, dataset.name + '_' + siamese.name + '_vectors')
project_embeddings(projection_vectors, emb_labels, siamese.name + '_' + dataset.name)
# save_vectors(projection_vectors, emb_labels, dataset.name + '_' + siamese.name + '_vectors')
project_embeddings(projection_vectors, emb_labels, str(MARGIN) + '_' + siamese.name + '_' + dataset.name)
print('Done!')
......@@ -17,7 +17,7 @@ def _save_vectors_path(values, labels, path):
data = [values, labels]
with bz2.BZ2File(path, 'wb') as f:
pickle.dump(data, f, -1)
pickle.dump(data, f, 4)
def _load_vectors_path(path):
......@@ -28,11 +28,11 @@ def _load_vectors_path(path):
def load_vectors(name='embeddings'):
return _load_vectors_path(get_datadir(name + '.pkl'))
return _load_vectors_path(get_datadir(name + '.pbz2'))
def save_vectors(values, labels, name='embeddings'):
return _save_vectors_path(values, labels, get_datadir(name + '.pkl'))
return _save_vectors_path(values, labels, get_datadir(name + '.pbz2'))
def export_vectors(values, labels, name='embeddings'):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment