Return the next `batch_size` examples from this data set.
(self, batch_size, start, max_captions)
| 164 | return ret_list |
| 165 | |
| 166 | def next_batch_test(self, batch_size, start, max_captions): |
| 167 | """Return the next `batch_size` examples from this data set.""" |
| 168 | if (start + batch_size) > self._num_examples: |
| 169 | end = self._num_examples |
| 170 | start = end - batch_size |
| 171 | else: |
| 172 | end = start + batch_size |
| 173 | |
| 174 | sampled_images = self._images[start:end] |
| 175 | sampled_images = sampled_images.astype(np.float32) |
| 176 | # from [0, 255] to [-1.0, 1.0] |
| 177 | sampled_images = sampled_images * (2. / 255) - 1. |
| 178 | sampled_images = self.transform(sampled_images) |
| 179 | |
| 180 | sampled_embeddings = self._embeddings[start:end] |
| 181 | _, embedding_num, _ = sampled_embeddings.shape |
| 182 | sampled_embeddings_batchs = [] |
| 183 | |
| 184 | sampled_captions = [] |
| 185 | sampled_filenames = self._filenames[start:end] |
| 186 | sampled_class_id = self._class_id[start:end] |
| 187 | for i in range(len(sampled_filenames)): |
| 188 | captions = self.readCaptions(sampled_filenames[i], |
| 189 | sampled_class_id[i]) |
| 190 | # print(captions) |
| 191 | sampled_captions.append(captions) |
| 192 | |
| 193 | for i in range(np.minimum(max_captions, embedding_num)): |
| 194 | batch = sampled_embeddings[:, i, :] |
| 195 | sampled_embeddings_batchs.append(np.squeeze(batch)) |
| 196 | |
| 197 | return [sampled_images, sampled_embeddings_batchs, |
| 198 | self._saveIDs[start:end], sampled_captions] |
| 199 | |
| 200 | |
| 201 | class TextDataset(object): |
no test coverage detected