From 0a68eadafa3a106f70a05ca4605b802930775535 Mon Sep 17 00:00:00 2001 From: Tilak <81610181+tilakrayal@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:39:37 +0530 Subject: [PATCH 1/2] Update gradient_centralization.py --- examples/vision/gradient_centralization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vision/gradient_centralization.py b/examples/vision/gradient_centralization.py index 7a016e62c3..aefc5e3e9f 100644 --- a/examples/vision/gradient_centralization.py +++ b/examples/vision/gradient_centralization.py @@ -151,7 +151,7 @@ def prepare(ds, shuffle=False, augment=False): subclass the `RMSProp` optimizer class modifying the `keras.optimizers.Optimizer.get_gradients()` method where we now implement Gradient Centralization. On a high level the idea is that let us say we obtain our gradients -through back propogation for a Dense or Convolution layer we then compute the mean of the +through back propagation for a Dense or Convolution layer we then compute the mean of the column vectors of the weight matrix, and then remove the mean from each column vector. The experiments in [this paper](https://arxiv.org/abs/2004.01461) on various From a940290b81580e10710953433e6474466b003b08 Mon Sep 17 00:00:00 2001 From: Tilak <81610181+tilakrayal@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:44:22 +0530 Subject: [PATCH 2/2] updated --- examples/vision/ipynb/gradient_centralization.ipynb | 13 +++++-------- examples/vision/md/gradient_centralization.md | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/vision/ipynb/gradient_centralization.ipynb b/examples/vision/ipynb/gradient_centralization.ipynb index c17e33056a..e2d9bef68a 100644 --- a/examples/vision/ipynb/gradient_centralization.ipynb +++ b/examples/vision/ipynb/gradient_centralization.ipynb @@ -64,8 +64,7 @@ "from keras import ops\n", "\n", "from tensorflow import data as tf_data\n", - "import tensorflow_datasets as tfds\n", - "" + "import tensorflow_datasets as tfds\n" ] }, { @@ -159,8 +158,7 @@ " )\n", "\n", " # Use buffered prefecting\n", - " return ds.prefetch(buffer_size=AUTOTUNE)\n", - "" + " return ds.prefetch(buffer_size=AUTOTUNE)\n" ] }, { @@ -238,7 +236,7 @@ "subclass the `RMSProp` optimizer class modifying the\n", "`keras.optimizers.Optimizer.get_gradients()` method where we now implement Gradient\n", "Centralization. On a high level the idea is that let us say we obtain our gradients\n", - "through back propogation for a Dense or Convolution layer we then compute the mean of the\n", + "through back propagation for a Dense or Convolution layer we then compute the mean of the\n", "column vectors of the weight matrix, and then remove the mean from each column vector.\n", "\n", "The experiments in [this paper](https://arxiv.org/abs/2004.01461) on various\n", @@ -314,8 +312,7 @@ " self.epoch_time_start = time()\n", "\n", " def on_epoch_end(self, batch, logs={}):\n", - " self.times.append(time() - self.epoch_time_start)\n", - "" + " self.times.append(time() - self.epoch_time_start)\n" ] }, { @@ -473,4 +470,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} diff --git a/examples/vision/md/gradient_centralization.md b/examples/vision/md/gradient_centralization.md index 413207c5fc..3e72396e31 100644 --- a/examples/vision/md/gradient_centralization.md +++ b/examples/vision/md/gradient_centralization.md @@ -170,7 +170,7 @@ We will now subclass the `RMSProp` optimizer class modifying the `keras.optimizers.Optimizer.get_gradients()` method where we now implement Gradient Centralization. On a high level the idea is that let us say we obtain our gradients -through back propogation for a Dense or Convolution layer we then compute the mean of the +through back propagation for a Dense or Convolution layer we then compute the mean of the column vectors of the weight matrix, and then remove the mean from each column vector. The experiments in [this paper](https://arxiv.org/abs/2004.01461) on various