Minimal-Bag-of-Visual-Words-Image-Classifier icon indicating copy to clipboard operation
Minimal-Bag-of-Visual-Words-Image-Classifier copied to clipboard

dict2numpy

Open buzzo123 opened this issue 8 years ago • 0 comments

hi, can i ask a question?

i want to implement a bag of words classifier in c# but i dont undestand this function:

def dict2numpy(dict):
    nkeys = len(dict)
    array = zeros((nkeys * PRE_ALLOCATION_BUFFER, 128))
    pivot = 0
    for key in dict.keys():
        value = dict[key]
        nelements = value.shape[0]
        while pivot + nelements > array.shape[0]:
            padding = zeros_like(array)
            array = vstack((array, padding))
        array[pivot:pivot + nelements] = value
        pivot += nelements
    array = resize(array, (pivot, 128))
    return array

can you explain me please? thanks a lot

buzzo123 avatar Feb 24 '17 13:02 buzzo123