Skip to content

Commit

Permalink
replace global batch_size with self.batch_size (keras-team#304)
Browse files Browse the repository at this point in the history
* Update oxford_pets_image_segmentation.py

Change batch_size to self.batch size; only works as written because there's a globally defined batch_size variable

* Update oxford_pets_image_segmentation.ipynb

* Update oxford_pets_image_segmentation.md
  • Loading branch information
Fluxionsdx authored Nov 11, 2020
1 parent 71acfaa commit 80ae4f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions examples/vision/ipynb/oxford_pets_image_segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@
" i = idx * self.batch_size\n",
" batch_input_img_paths = self.input_img_paths[i : i + self.batch_size]\n",
" batch_target_img_paths = self.target_img_paths[i : i + self.batch_size]\n",
" x = np.zeros((batch_size,) + self.img_size + (3,), dtype=\"float32\")\n",
" x = np.zeros((self.batch_size,) + self.img_size + (3,), dtype=\"float32\")\n",
" for j, path in enumerate(batch_input_img_paths):\n",
" img = load_img(path, target_size=self.img_size)\n",
" x[j] = img\n",
" y = np.zeros((batch_size,) + self.img_size + (1,), dtype=\"uint8\")\n",
" y = np.zeros((self.batch_size,) + self.img_size + (1,), dtype=\"uint8\")\n",
" for j, path in enumerate(batch_target_img_paths):\n",
" img = load_img(path, target_size=self.img_size, color_mode=\"grayscale\")\n",
" y[j] = np.expand_dims(img, 2)\n",
Expand Down Expand Up @@ -390,4 +390,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
4 changes: 2 additions & 2 deletions examples/vision/md/oxford_pets_image_segmentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ class OxfordPets(keras.utils.Sequence):
i = idx * self.batch_size
batch_input_img_paths = self.input_img_paths[i : i + self.batch_size]
batch_target_img_paths = self.target_img_paths[i : i + self.batch_size]
x = np.zeros((batch_size,) + self.img_size + (3,), dtype="float32")
x = np.zeros((self.batch_size,) + self.img_size + (3,), dtype="float32")
for j, path in enumerate(batch_input_img_paths):
img = load_img(path, target_size=self.img_size)
x[j] = img
y = np.zeros((batch_size,) + self.img_size + (1,), dtype="uint8")
y = np.zeros((self.batch_size,) + self.img_size + (1,), dtype="uint8")
for j, path in enumerate(batch_target_img_paths):
img = load_img(path, target_size=self.img_size, color_mode="grayscale")
y[j] = np.expand_dims(img, 2)
Expand Down
4 changes: 2 additions & 2 deletions examples/vision/oxford_pets_image_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ def __getitem__(self, idx):
i = idx * self.batch_size
batch_input_img_paths = self.input_img_paths[i : i + self.batch_size]
batch_target_img_paths = self.target_img_paths[i : i + self.batch_size]
x = np.zeros((batch_size,) + self.img_size + (3,), dtype="float32")
x = np.zeros((self.batch_size,) + self.img_size + (3,), dtype="float32")
for j, path in enumerate(batch_input_img_paths):
img = load_img(path, target_size=self.img_size)
x[j] = img
y = np.zeros((batch_size,) + self.img_size + (1,), dtype="uint8")
y = np.zeros((self.batch_size,) + self.img_size + (1,), dtype="uint8")
for j, path in enumerate(batch_target_img_paths):
img = load_img(path, target_size=self.img_size, color_mode="grayscale")
y[j] = np.expand_dims(img, 2)
Expand Down

0 comments on commit 80ae4f7

Please sign in to comment.