weighted_loss = WeightedError(in_layers=[loss, weights])
self.set_loss(weighted_loss)
def default_generator(self,
dataset,
epochs=1,
predict=False,
deterministic=True,
pad_batches=True):
Transfer smiles strings to fixed length integer vectors
for epoch in range(epochs):
for (X_b, y_b, w_b, ids_b) in dataset.iterbatches(
batch_size=self.batch_size,
deterministic=deterministic,
pad_batches=pad_batches):
feed_dict = dict()
if y_b is not None and not predict:
if self.mode == "classification":
feed_dict[self.labels[0]] = to_one_hot(y_b.flatten(), 2).reshape(
-1, self.n_tasks, 2)
else:
feed_dict[self.labels[0]] = y_b
if w_b is not None and not predict:
feed_dict[self.task_weights[0]] = w_b
// Transform SMILES sequence to integers
smiles_seqs = [self.smiles_to_seq(smiles) for smiles in ids_b]