Пример #1
0
  def construct_feed_dict(self, X_b, y_b=None, w_b=None, training=True):
    """Get initial information about task normalization"""
    # TODO(rbharath): I believe this is total amount of data
    n_samples = len(X_b)
    if y_b is None:
      y_b = np.zeros((n_samples, self.n_tasks))
    if w_b is None:
      w_b = np.zeros((n_samples, self.n_tasks))
    targets_dict = {self.label_placeholder : y_b,
                    self.weight_placeholder : w_b}
    
    # Get graph information
    atoms_dict = self.graph_topology.batch_to_feed_dict(X_b)

    # TODO (hraut->rhbarath): num_datapoints should be a vector, with ith element being
    # the number of labeled data points in target_i. This is to normalize each task
    # num_dat_dict = {self.num_datapoints_placeholder : self.}

    # Get other optimizer information
    # TODO(rbharath): Figure out how to handle phase appropriately
    #keras_dict = {K.learning_phase() : training}
    keras_dict = {}
    feed_dict = merge_dicts([targets_dict, atoms_dict,
                             keras_dict])
    return feed_dict
Пример #2
0
    def construct_feed_dict(self, X_b, y_b=None, w_b=None, training=True):
        """Get initial information about task normalization"""
        # TODO(rbharath): I believe this is total amount of data
        n_samples = len(X_b)
        if y_b is None:
            y_b = np.zeros((n_samples, self.n_tasks))
        if w_b is None:
            w_b = np.zeros((n_samples, self.n_tasks))
        targets_dict = {
            self.label_placeholder: y_b,
            self.weight_placeholder: w_b
        }

        # Get graph information
        atoms_dict = self.graph_topology.batch_to_feed_dict(X_b)

        # TODO (hraut->rhbarath): num_datapoints should be a vector, with ith element being
        # the number of labeled data points in target_i. This is to normalize each task
        # num_dat_dict = {self.num_datapoints_placeholder : self.}

        # Get other optimizer information
        # TODO(rbharath): Figure out how to handle phase appropriately
        #keras_dict = {K.learning_phase() : training}
        keras_dict = {}
        feed_dict = merge_dicts([targets_dict, atoms_dict, keras_dict])
        return feed_dict
Пример #3
0
  def construct_feed_dict(self, test, support, training=True, add_phase=False):
    """Constructs tensorflow feed from test/support sets."""
    # Generate dictionary elements for support 
    feed_dict = (
        self.model.support_graph_topology.batch_to_feed_dict(support.X))
    feed_dict[self.support_label_placeholder] = np.squeeze(support.y)
    # Get graph information for test 
    batch_topo_dict = (
        self.model.test_graph_topology.batch_to_feed_dict(test.X))
    feed_dict = merge_dicts([batch_topo_dict, feed_dict])
    # Generate dictionary elements for test
    feed_dict[self.test_label_placeholder] = np.squeeze(test.y)
    feed_dict[self.test_weight_placeholder] = np.squeeze(test.w)

    # Get information for keras 
    if add_phase:
      feed_dict[K.learning_phase()] = training
    return feed_dict
Пример #4
0
    def construct_feed_dict(self,
                            test,
                            support,
                            training=True,
                            add_phase=False):
        """Constructs tensorflow feed from test/support sets."""
        # Generate dictionary elements for support
        feed_dict = (self.model.support_graph_topology.batch_to_feed_dict(
            support.X))
        feed_dict[self.support_label_placeholder] = np.squeeze(support.y)
        # Get graph information for test
        batch_topo_dict = (self.model.test_graph_topology.batch_to_feed_dict(
            test.X))
        feed_dict = merge_dicts([batch_topo_dict, feed_dict])
        # Generate dictionary elements for test
        feed_dict[self.test_label_placeholder] = np.squeeze(test.y)
        feed_dict[self.test_weight_placeholder] = np.squeeze(test.w)

        # Get information for keras
        if add_phase:
            feed_dict[K.learning_phase()] = training
        return feed_dict