fix: use hasattr() to check if collate_fn is in dataloader
fix bug caused by PR
@@ -161,7 +161,7 @@ class Engine(object):
if metric_config is not None:
metric_config = metric_config.get("Train")
if metric_config is not None:
- if self.train_dataloader.collate_fn:
+ if hasattr(self.train_dataloader, "collate_fn"):
for m_idx, m in enumerate(metric_config):
if "TopkAcc" in m:
msg = f"'TopkAcc' metric can not be used when setting 'batch_transform_ops' in config. The 'TopkAcc' metric has been removed."
