def construct_feed_dict(self, X_b, y_b=None, w_b=None, ids_b=None): """Construct a feed dictionary from minibatch data. TODO(rbharath): ids_b is not used here. Can we remove it? Args: X_b: np.ndarray of shape (batch_size, n_features) y_b: np.ndarray of shape (batch_size, n_tasks) w_b: np.ndarray of shape (batch_size, n_tasks) ids_b: List of length (batch_size) with datapoint identifiers. """ orig_dict = {} orig_dict["mol_features"] = X_b for task in range(self.n_tasks): if y_b is not None: orig_dict["labels_%d" % task] = to_one_hot(y_b[:, task]) else: # Dummy placeholders orig_dict["labels_%d" % task] = np.squeeze(to_one_hot( np.zeros((self.batch_size,)))) if w_b is not None: orig_dict["weights_%d" % task] = w_b[:, task] else: # Dummy placeholders orig_dict["weights_%d" % task] = np.ones( (self.batch_size,)) return TensorflowGraph.get_feed_dict(orig_dict)
def construct_feed_dict(self, X_b, y_b=None, w_b=None, ids_b=None): """Construct a feed dictionary from minibatch data. TODO(rbharath): ids_b is not used here. Can we remove it? Args: X_b: np.ndarray of shape (batch_size, n_features) y_b: np.ndarray of shape (batch_size, n_tasks) w_b: np.ndarray of shape (batch_size, n_tasks) ids_b: List of length (batch_size) with datapoint identifiers. """ orig_dict = {} orig_dict["mol_features"] = X_b for task in range(self.n_tasks): if y_b is not None: orig_dict["labels_%d" % task] = to_one_hot(y_b[:, task]) else: # Dummy placeholders orig_dict["labels_%d" % task] = np.squeeze( to_one_hot(np.zeros((self.batch_size, )))) if w_b is not None: orig_dict["weights_%d" % task] = w_b[:, task] else: # Dummy placeholders orig_dict["weights_%d" % task] = np.ones((self.batch_size, )) return TensorflowGraph.get_feed_dict(orig_dict)
def construct_task_feed_dict(self, this_task, X_b, y_b=None, w_b=None, ids_b=None): """Construct a feed dictionary from minibatch data. TODO(rbharath): ids_b is not used here. Can we remove it? Args: X_b: np.ndarray of shape (batch_size, n_features) y_b: np.ndarray of shape (batch_size, n_tasks) w_b: np.ndarray of shape (batch_size, n_tasks) ids_b: List of length (batch_size) with datapoint identifiers. """ orig_dict = {} orig_dict["mol_features"] = X_b n_samples = len(X_b) for task in range(self.n_tasks): if (this_task == task) and y_b is not None: #orig_dict["labels_%d" % task] = np.reshape(y_b[:, task], (n_samples, 1)) orig_dict["labels_%d" % task] = np.reshape(y_b[:, task], (n_samples,)) else: # Dummy placeholders #orig_dict["labels_%d" % task] = np.zeros((n_samples, 1)) orig_dict["labels_%d" % task] = np.zeros((n_samples,)) if (this_task == task) and w_b is not None: #orig_dict["weights_%d" % task] = np.reshape(w_b[:, task], (n_samples, 1)) orig_dict["weights_%d" % task] = np.reshape(w_b[:, task], (n_samples,)) else: # Dummy placeholders #orig_dict["weights_%d" % task] = np.zeros((n_samples, 1)) orig_dict["weights_%d" % task] = np.zeros((n_samples,)) return TensorflowGraph.get_feed_dict(orig_dict)
def construct_feed_dict(self, X_b, y_b=None, w_b=None, ids_b=None): orig_dict = {} orig_dict["mol_features"] = X_b for task in range(self.n_tasks): if y_b is not None: y_2column = to_one_hot(y_b[:, task]) # fix the size to be [?,1] orig_dict["labels_%d" % task] = y_2column[:, 1:2] else: # Dummy placeholders orig_dict["labels_%d" % task] = np.zeros((self.batch_size, 1)) if w_b is not None: orig_dict["weights_%d" % task] = w_b[:, task] else: # Dummy placeholders orig_dict["weights_%d" % task] = np.ones((self.batch_size,)) return TensorflowGraph.get_feed_dict(orig_dict)
def construct_feed_dict(self, X_b, y_b=None, w_b=None, ids_b=None): orig_dict = {} orig_dict["mol_features"] = X_b for task in range(self.n_tasks): if y_b is not None: y_2column = to_one_hot(y_b[:, task]) # fix the size to be [?,1] orig_dict["labels_%d" % task] = y_2column[:, 1:2] else: # Dummy placeholders orig_dict["labels_%d" % task] = np.zeros((self.batch_size, 1)) if w_b is not None: orig_dict["weights_%d" % task] = w_b[:, task] else: # Dummy placeholders orig_dict["weights_%d" % task] = np.ones((self.batch_size, )) return TensorflowGraph.get_feed_dict(orig_dict)