Exemplo n.º 1
0
 def __init__(self, directory, pixel_noise_stddev=0.0):
     values = dict(world1='world',
                   world2='world',
                   world3='world',
                   world_model1='model',
                   world_model2='model',
                   world_model3='model',
                   description='language',
                   description_length='int',
                   description_model='model',
                   agreement='float')
     world_size = tuple(
         next(nlvr_util.images_iter(directory=directory,
                                    mode='train'))[1][0].shape[:2])
     self.description_size = 0
     vocabulary = set()
     for _, _, description, _ in nlvr_util.descriptions_iter(
             directory=directory, mode='train'):
         self.description_size = max(self.description_size,
                                     len(description))
         vocabulary.update(description)
     vocabularies = dict(language=sorted(vocabulary))
     super(NLVR,
           self).__init__(values=values,
                          world_size=world_size,
                          pixel_noise_stddev=pixel_noise_stddev,
                          vectors=dict(description=self.description_size),
                          vocabularies=vocabularies)
     self.nlvr = {
         mode: nlvr_util.nlvr(directory=directory, mode=mode)
         for mode in ('train', 'validation', 'test')
     }
Exemplo n.º 2
0
 def __init__(self, directory):
     world_size = tuple(next(nlvr_util.images_iter(directory=directory, mode='train'))[1][0].shape[:2])
     self.description_size = 0
     vocabulary = set()
     for _, _, description, _ in nlvr_util.descriptions_iter(directory=directory, mode='train'):
         self.description_size = max(self.description_size, len(description))
         vocabulary.update(description)
     vocabularies = dict(language=sorted(vocabulary))
     super(NLVR, self).__init__(world_size=world_size, vectors=dict(description=self.description_size), vocabularies=vocabularies)
     self.nlvr = {mode: nlvr_util.nlvr(directory=directory, mode=mode) for mode in ('train', 'validation', 'test')}
Exemplo n.º 3
0
 def __init__(self, directory):
     world_size = tuple(
         next(nlvr_util.images_iter(directory=directory,
                                    mode='train'))[1][0].shape[:2])
     self.description_size = 0
     words = set()
     for _, _, description, _ in nlvr_util.descriptions_iter(
             directory=directory, mode='train'):
         description = util.string2tokens(string=description)
         self.description_size = max(self.description_size,
                                     len(description))
         words.update(description)
     words = sorted(words)
     super(NLVRDataset,
           self).__init__(world_size=world_size,
                          vectors=dict(description=self.description_size),
                          words=words)
     self.nlvr = {
         mode: nlvr_util.nlvr(directory=directory, mode=mode)
         for mode in ('train', 'validation', 'test')
     }