# Path: autoencoder/utils/op_utils.py
# def unitmatrix(matrix, norm='l2', axis=1):
#     if norm == 'l1':
#         maxtrixlen = np.sum(np.abs(matrix), axis=axis)
#     if norm == 'l2':
#         maxtrixlen = np.linalg.norm(matrix, axis=axis)
# 
#     if np.any(maxtrixlen <= 0):
#         return matrix
#     else:
#         maxtrixlen = maxtrixlen.reshape(1, len(maxtrixlen)) if axis == 0 else maxtrixlen.reshape(len(maxtrixlen), 1)
#         return matrix / maxtrixlen


import numpy as np
    import pdb;pdb.set_trace()
from collections import defaultdict, Counter
from keras.models import Sequential
from keras.layers import Dense
from keras.callbacks import EarlyStopping, ReduceLROnPlateau
from autoencoder.utils.op_utils import unitmatrix
'''
Created on Jan, 2017

@author: hugo

'''
from __future__ import absolute_import
# from keras.optimizers import Adam



def retrieval(X_train, Y_train, X_test, Y_test, fractions=[0.01, 0.5, 1.0], multilabel=False):
    db_size = len(X_train)
    n_queries = len(X_test)

# Path: autoencoder/utils/op_utils.py
# def unitmatrix(matrix, norm='l2', axis=1):
#     if norm == 'l1':
#         maxtrixlen = np.sum(np.abs(matrix), axis=axis)
#     if norm == 'l2':
#         maxtrixlen = np.linalg.norm(matrix, axis=axis)
# 
#     if np.any(maxtrixlen <= 0):
#         return matrix
#     else:
#         maxtrixlen = maxtrixlen.reshape(1, len(maxtrixlen)) if axis == 0 else maxtrixlen.reshape(len(maxtrixlen), 1)
#         return matrix / maxtrixlen


# Path: autoencoder/testing/retrieval.py
import numpy as np
    import pdb;pdb.set_trace()
from collections import defaultdict, Counter
from keras.models import Sequential
from keras.layers import Dense
from keras.callbacks import EarlyStopping, ReduceLROnPlateau
from autoencoder.utils.op_utils import unitmatrix

'''
Created on Jan, 2017

@author: hugo

'''
from __future__ import absolute_import
# from keras.optimizers import Adam



def retrieval(X_train, Y_train, X_test, Y_test, fractions=[0.01, 0.5, 1.0], multilabel=False):
    db_size = len(X_train)
    n_queries = len(X_test)

    X_train = unitmatrix(X_train) # normalize