polyvore_outfits.py
def load_typespaces(rootdir, rand_typespaces, num_rand_embed):
    """ loads a mapping of pairs of types to the embedding used to
        compare them

        rand_typespaces: Boolean indicator of randomly assigning type
                         specific spaces to their embedding
        num_rand_embed: number of embeddings to use when
                        rand_typespaces is true
    """
    typespace_fn = os.path.join(rootdir, 'typespaces.p')
    typespaces = pickle.load(open(typespace_fn,'rb'))
    if not rand_typespaces:
        ts = {}
        for index, t in enumerate(typespaces):
            ts[t] = index

        typespaces = ts
        return typespaces

    # load a previously created random typespace or create one
    # if none exist
    width = 0
    fn = os.path.join(rootdir, 'typespaces_rand_%i.p') % num_rand_embed
    if os.path.isfile(fn):
        typespaces = pickle.load(open(fn, 'rb'))
    else:
        spaces = np.random.permutation(len(typespaces))
        width = np.ceil(len(spaces) / float(num_rand_embed))
        ts = {}
        for index, t in enumerate(spaces):
            ts[typespaces[t]] = int(np.floor(index / width))

        typespaces = ts
        pickle.dump(typespaces, open(fn, 'wb'))

    return typespaces
 loads a mapping of pairs of types to the embedding used to
        compare them

        rand_typespaces: Boolean indicator of randomly assigning type
                         specific spaces to their embedding
        num_rand_embed: number of embeddings to use when
                        rand_typespaces is true
    
loads a mapping of pairs of types to the embedding used to
compare them

Boolean indicator of randomly assigning type
specific spaces to their embedding
num_rand_embed: number of embeddings to use when
rand_typespaces is true
loads a mapping of pairs of types to the embedding used to compare them Boolean indicator of randomly assigning type specific spaces to their embedding num_rand_embed : number of embeddings to use when rand_typespaces is true
def load_typespaces(rootdir, rand_typespaces, num_rand_embed):
    typespace_fn = os.path.join(rootdir, 'typespaces.p')
    typespaces = pickle.load(open(typespace_fn,'rb'))
    if not rand_typespaces:
        ts = {}
        for index, t in enumerate(typespaces):
            ts[t] = index
        typespaces = ts
        return typespaces
    width = 0
    fn = os.path.join(rootdir, 'typespaces_rand_%i.p') % num_rand_embed
    if os.path.isfile(fn):
        typespaces = pickle.load(open(fn, 'rb'))
    else:
        spaces = np.random.permutation(len(typespaces))
        width = np.ceil(len(spaces) / float(num_rand_embed))
        ts = {}
        for index, t in enumerate(spaces):
            ts[typespaces[t]] = int(np.floor(index / width))
        typespaces = ts
        pickle.dump(typespaces, open(fn, 'wb'))
    return typespaces
def load_typespaces ( rootdir , rand_typespaces , num_rand_embed ) : typespace_fn = os . path . join ( rootdir , 'typespaces.p' ) typespaces = pickle . load ( open ( typespace_fn , 'rb' ) ) if not rand_typespaces : ts = { } for index , t in enumerate ( typespaces ) : ts [ t ] = index typespaces = ts return typespaces width = 0 fn = os . path . join ( rootdir , 'typespaces_rand_%i.p' ) % num_rand_embed if os . path . isfile ( fn ) : typespaces = pickle . load ( open ( fn , 'rb' ) ) else : spaces = np . random . permutation ( len ( typespaces ) ) width = np . ceil ( len ( spaces ) / float ( num_rand_embed ) ) ts = { } for index , t in enumerate ( spaces ) : ts [ typespaces [ t ] ] = int ( np . floor ( index / width ) ) typespaces = ts pickle . dump ( typespaces , open ( fn , 'wb' ) ) return typespaces
loads a mapping of pairs of types to the embedding used to
compare them
loads a mapping of pairs of types to the embedding used to compare them
""" loads a mapping of pairs of types to the embedding used to
        compare them

        rand_typespaces: Boolean indicator of randomly assigning type
                         specific spaces to their embedding
        num_rand_embed: number of embeddings to use when
                        rand_typespaces is true
    """ # load a previously created random typespace or create one # if none exist
rootdir
rand_typespaces
num_rand_embed