wangz10 / tensorflow-playground

Implementations of some Deep Learning models using tensorflow with scikit-learn like APIs
MIT License
80 stars 34 forks source link

Problem with generate_batch_cbow(data,batch_size, num_skips=2, skip_window=2) #2

Open gourango01 opened 8 years ago

gourango01 commented 8 years ago

ValueError: cannot copy sequence with size 4 to array axis with dimension 2.

romusters commented 8 years ago

Got a solution, but I did not check it for correctness. It involves making the mask for the sliding windows fit your dimensions.

LopezGG commented 7 years ago

Here is what i did

    # move the sliding window  
    for i in range(batch_size):
        mask = [0] * span
        # taking context words equal to num_skips
        for ns in range(0,num_skips):
            posNumber = random.randint(0,span-1)
            while (posNumber == skip_window or or mask[posNumber]== 1):
                posNumber = random.randint(0,span-1)
            mask[posNumber]=1