Minimal-Bag-of-Visual-Words-Image-Classifier
Minimal-Bag-of-Visual-Words-Image-Classifier copied to clipboard
dict2numpy
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