Esempio n. 1
0
    def make_input(self, batch_dict, train=False):
        """When we are running with `DataFeed`s, need to transform to `feed_dict`s

        :param batch_dict: The batch for a step
        :param train: (`bool`) Are we training (or evaluating)?
        :return: A `feed_dict`
        """
        if not tf.executing_eagerly():
            batch_dict_for_model = new_placeholder_dict(train)

            for key in self.src_keys:
                batch_dict_for_model["{}:0".format(key)] = batch_dict[key]

            y = batch_dict.get('y')
            if y is not None:
                batch_dict_for_model[self.y] = batch_dict['y']

        else:
            SET_TRAIN_FLAG(train)

            batch_dict_for_model = {}
            for key in self.src_keys:
                batch_dict_for_model[key] = batch_dict[key]

        return batch_dict_for_model
Esempio n. 2
0
    def make_input(self, batch_dict, train=False):
        """Transform a `batch_dict` into a TensorFlow `feed_dict`

        :param batch_dict: (``dict``) A dictionary containing all inputs to the embeddings for this model
        :param train: (``bool``) Are we training.  Defaults to False
        :return:
        """
        y = batch_dict.get('y', None)
        if not tf.executing_eagerly():
            batch_for_model = new_placeholder_dict(train)

            for k in self.embeddings.keys():
                batch_for_model["{}:0".format(k)] = batch_dict[k]

            # Allow us to track a length, which is needed for BLSTMs
            if self.lengths_key is not None:
                batch_for_model[self.lengths] = batch_dict[self.lengths_key]

            if y is not None:
                batch_for_model[self.y] = fill_y(len(self.labels), y)

        else:
            SET_TRAIN_FLAG(train)
            batch_for_model = {}
            for k in self.embeddings.keys():
                batch_for_model[k] = batch_dict[k]

            # Allow us to track a length, which is needed for BLSTMs
            if self.lengths_key is not None:
                batch_for_model["lengths"] = batch_dict[self.lengths_key]

        return batch_for_model
Esempio n. 3
0
    def make_input(self, batch_dict, train=False):
        if train is False:
            return self.inference.make_input(batch_dict)

        y = batch_dict.get('y', None)
        feed_dict = new_placeholder_dict(True)

        for key in self.parallel_params.keys():
            feed_dict["{}_parallel:0".format(key)] = batch_dict[key]

        # Allow us to track a length, which is needed for BLSTMs
        if self.lengths_key is not None:
            feed_dict[self.lengths] = batch_dict[self.lengths_key]

        if y is not None:
            feed_dict[self.y] = fill_y(len(self.labels), y)
        return feed_dict
Esempio n. 4
0
    def make_input(self, batch_dict, train=False):
        if train is False:
            return self.inference.make_input(batch_dict)

        y = batch_dict.get('y', None)
        feed_dict = new_placeholder_dict(True)

        for key in self.parallel_params.keys():
            feed_dict["{}_parallel:0".format(key)] = batch_dict[key]

        # Allow us to track a length, which is needed for BLSTMs
        if self.lengths_key is not None:
            feed_dict[self.lengths] = batch_dict[self.lengths_key]

        if y is not None:
            feed_dict[self.y] = fill_y(len(self.labels), y)
        return feed_dict
Esempio n. 5
0
    def make_input(self, batch_dict, train=False):
        """Transform a `batch_dict` into a TensorFlow `feed_dict`

        :param batch_dict: (``dict``) A dictionary containing all inputs to the embeddings for this model
        :param train: (``bool``) Are we training.  Defaults to False
        :return:
        """
        y = batch_dict.get('y', None)
        feed_dict = new_placeholder_dict(train)

        for k in self.embeddings.keys():
            feed_dict["{}:0".format(k)] = batch_dict[k]

        # Allow us to track a length, which is needed for BLSTMs
        if self.lengths_key is not None:
            feed_dict[self.lengths] = batch_dict[self.lengths_key]

        if y is not None:
            feed_dict[self.y] = fill_y(len(self.labels), y)

        return feed_dict
 def make_input(self, batch_dict):
     feed_dict = new_placeholder_dict(False)
     for k in self.embeddings.keys():
         feed_dict["{}:0".format(k)] = batch_dict[k]
     return feed_dict