This function takes a batch and returns individual records from it. It is necessary for tf.keras generators
(loader)
| 166 | return x |
| 167 | |
| 168 | def record_generator(loader): |
| 169 | """ |
| 170 | This function takes a batch and returns individual records from it. |
| 171 | |
| 172 | It is necessary for tf.keras generators |
| 173 | """ |
| 174 | my_iter = iter(loader) |
| 175 | for x_batch, y_batch in my_iter: |
| 176 | if isinstance(x_batch, list) and isinstance(x_batch[0], np.ndarray): |
| 177 | if isinstance(y_batch, list) and isinstance(y_batch[0], np.ndarray): |
| 178 | for i in range(len(x_batch[0])): |
| 179 | yield tuple([xb[i] for xb in x_batch]), tuple([yb[i] for yb in y_batch]) |
| 180 | else: |
| 181 | for i in range(len(x_batch[0])): |
| 182 | yield tuple([xb[i] for xb in x_batch]), y_batch[i] |
| 183 | else: |
| 184 | if isinstance(y_batch, list) and isinstance(y_batch[0], np.ndarray): |
| 185 | for i in range(len(x_batch)): |
| 186 | yield x_batch[i], tuple([yb[i] for yb in y_batch]) |
| 187 | else: |
| 188 | for i in range(len(x_batch)): |
| 189 | yield x_batch[i], y_batch[i] |
no outgoing calls