What is the method as a sampler of tensorflow?


(Changlin Zhang) #1

I want to generate negative samples.
In tensorflow, it could use tf.nn.fixed_unigram_candidate_sampler to give it true labels so that it can guarantee negative samples wont have true labels.

        self.neg_samples, _, _ = (tf.nn.fixed_unigram_candidate_sampler(
            true_classes=labels,
            num_true=1,
            num_sampled=FLAGS.neg_sample_size,
            unique=False,
            range_max=len(self.degrees),
            distortion=0.75,
            unigrams=self.degrees.tolist()))

But how to achieve this function in pytorch?