Update TensorFlow Task Runner and related workspaces
Related Issue: #973
Summary: This PR aims to update the TensorFlow Task Runner to use Keras as the high-level API, which is in line with best practices as well as updates existing TF workspaces. This enables the usage of non-legacy optimizers (which will be deprecated in future versions of TF/Keras)
Specifically, this PR:
- Creates a new
TensorFlowTaskRunnerclass inopenfl.federated.task.runner_tfwhich borrows heavily from theKerasTaskRunnertask. Major difference is in handling the weights of the optimizer which was necessitated by the removal of the.get_weight()and.weights()attributes from the optimizer. This newTensorFlowTaskRunnerextracts weights from the.variables()attribute- Also updated the train and validation task names to
train_validationandtask_validationto be consistent with the torch taskrunner
- Also updated the train and validation task names to
- Archived old
TensorFlowTaskRunnerasTensorFlowTaskRunner_v1withinopenfl.federated.task.runner_tfand updated the__init__files to make it callable. Rationale is to avoid any breaking changes for tutorials or upstream applications that still relied on the low-level TF taskrunner. This can be removed entirely in a future release as needed- Also updated the train and validation task names to
train_validationandtask_validationto be consistent with the torch taskrunner
- Also updated the train and validation task names to
- Created a new
tf_cnn_mnistworkspace and updated thetorch_cnn_histologyworkspace to run on the newTensorFlowTaskRunnerusing thesrc/dataloader.pyandsrc/taskrunner.pyconvention.- update to
TensorFlow v2.15.1(latest TensorFlow to not useKeras v3.xby default)
- update to
- Minor
tf_3dunet_bratsto use newTensorFlowTaskRunner(did not make changes tosrcfiles because I did not have Brats3D dataset to verify a large update - Minor updates to
tf_2dunetto run on archivedTensorFlowTaskRunner_v1
Future work
- Consolidation step still needed:
- Migrate all
tf_2d_unetfromTensorFlowTaskRunner_v1to newTensorFlowTaskRunner - Migrate all keras workspaces from
KerasTaskRunnerto newTensorFlowTaskRunnerand remove/archive KerasTaskRunner
- Migrate all
- Look into updated
TensorFlowTaskRunnerto run onTF v2.16+withKeras 3.x(this may need some large changes to weight handling that will likely not have backwards compatibility)
Most of my comments are nitpicks around naming/formatting and/or structure. Please disposition as you find relevant.
Also, do we need TF v1 (tf.Session API) task runners? These are ancient APIs that none of the community uses. Does OpenFL have users on this legacy TF API?
Most of my comments are nitpicks around naming/formatting and/or structure. Please disposition as you find relevant. Also, do we need TF v1 (
tf.SessionAPI) task runners? These are ancient APIs that none of the community uses. Does OpenFL have users on this legacy TF API?
@MasterSkepticista I agree the TF v1 / Legacy task runners can be removed at this point.
Thanks @MasterSkepticista @psfoley ! I will get back to addressing these comments once I'm done with some other pressing tasks. I appreciate the review
Most of my comments are nitpicks around naming/formatting and/or structure. Please disposition as you find relevant. Also, do we need TF v1 (
tf.SessionAPI) task runners? These are ancient APIs that none of the community uses. Does OpenFL have users on this legacy TF API?@MasterSkepticista I agree the TF v1 / Legacy task runners can be removed at this point.
Great, I am also in agreement with removing the old TF runner. Actually, one reason why I did not propose it directly in this PR was because the tf2dunet workspaces uses the old TF runner. I can update it, but since it uses the BraTS dataset, I will have to get approval so I can test it
Thank you @kta-intel. This was completed by https://github.com/securefederatedai/openfl/pull/1174.