Skip to content

Instantly share code, notes, and snippets.

@yurkor
yurkor / 3d_images_match.py
Last active July 13, 2016 00:23
avito_deep_learning
"""
train on seq_of_iamges vs seq_of_images -> {0,1} sigmoid or contrastive_loss
"""
# model.load_weights("checkpoint_model.h5")
def euclidean_distance(vects):
x, y = vects
return K.sqrt(K.sum(K.square(x - y), axis=1, keepdims=True))
def iterate_minibatches(inputs, targets, batchsize, shuffle=False):
assert len(inputs) == len(targets)
while True:
if shuffle:
indices = np.arange(len(inputs))
np.random.shuffle(indices)
for start_idx in range(0, len(inputs) - batchsize + 1, batchsize):
if shuffle:
excerpt = indices[start_idx:start_idx + batchsize]
else: