fast-dog-88545
06/21/2023, 3:39 PMtensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot convert a Tensor of dtype variant to a NumPy array.
I have tested the training codes work without metaflow. This happens in the train step, but after all the operation in train step done. So I guess this error may be related to metaflow. Does anyone have some ideas about this? Thanks!
The training codes with metaflow are here, the notebook for the training without metaflow is here.victorious-lawyer-58417
06/21/2023, 3:45 PMtrain step
self.tf_train_ds = to_tf_dataset(train_ds)
self.tf_valid_ds = to_tf_dataset(valid_ds)
Try dropping the self. here to see if it helpsfast-dog-88545
06/21/2023, 3:48 PMvictorious-lawyer-58417
06/21/2023, 3:49 PMfast-dog-88545
06/21/2023, 3:50 PMfast-dog-88545
06/21/2023, 3:53 PMvictorious-lawyer-58417
06/21/2023, 3:55 PMself. automatically when a task finishes which is why the error happens at the end of the task, as you observed. It does this so you can run tasks in different environments seamlessly (e.g. train in the cloud and the next step locally etc), and also to help keeping track of everything.
It uses Python default serialization pickle to convert objects to bytes, which works in most cases but some libraries are not very pickle-friendly, Tensorflow being one of them. Things related to Tensorflow tend to require a bit special treatment (e.g. see this example that serializes Keras models). PyTorch tends to be more pickle-friendly.
Similar to that Keras example, if you wanted to persist these objects as artifacts, you'd need to wrap them in a few extra lines that use Tensorflow's internal serialization methods. I'm happy to help you with that if needed.