sorenbouma/keras-oneshot

Missing indices in make_oneshot_task

Closed this issue · 1 comments

Hi,

first of all thanks for the implementation, very useful to understand the paper and compare with own implementation !

Here is a small bug with make_oneshot_task :

        if language is not None:
            low, high = self.categories[s][language]
            if N > high - low:
                raise ValueError("This language ({}) has less than {} letters".format(language, N))
            categories = rng.choice(range(low,high),size=(N,),replace=False)
            indices = rng.randint(0,self.n_examples,size=(N,))
            
        else:#if no language specified just pick a bunch of random letters
            categories = rng.choice(range(n_classes),size=(N,),replace=False)            

array of indices is not defined in the else case.

Probably, this fixes the problem

else:#if no language specified just pick a bunch of random letters
    categories = rng.choice(range(n_classes),size=(N,),replace=False)            
    indices = rng.randint(0,self.n_examples,size=(N,))

HTH

My bad, I must have added this in a commit that was supposed to fix bugs haha - I'm still learning. Thanks for opening this issue, it should be fixed now.