materialsvirtuallab / m3gnet

Materials graph network with 3-body interactions featuring a DFT surrogate crystal relaxer and a state-of-the-art property predictor.
BSD 3-Clause "New" or "Revised" License
243 stars 62 forks source link

Validation Structures of None results in termination for PotentialTrainer #73

Open danielsauceda opened 1 year ago

danielsauceda commented 1 year ago

It seems when doing

trainer = PotentialTrainer(
    potential=potential, optimizer=tf.keras.optimizers.Adam(1e-3)
)

That if no Validation sets are provided. then the entire endeavor fails. This would be because of difference in the Trainer class which has the following condition

          if has_validation:
                val_predictions = []
                val_targets = []
                for val_index, batch in enumerate(mgb_val):
                    graph_batch, target_batch = batch
                    if isinstance(graph_batch, MaterialGraph):

Whereas PotentialTrainer does not and attempts do.

            for batch_index, batch in enumerate(mgb_val):
                graph_batch, target_batch = batch

and since "mgb_val" is not set it fails since the "has_validation" condition is not utilized