Git Product home page Git Product logo

keras-balanced-batch-generator's People

Contributors

soroushj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

keras-balanced-batch-generator's Issues

Error for custom input batch

`Epoch 1/80
665/665 [==============================] - ETA: 0s - loss: -inf - reid_output_loss: 6.7618 - l2_loss: -inf - reid_output_accuracy: 0.0012 - reid_output_lr: 3.0486e-07 - l2_accuracy: 0.0012 - l2_lr: 3.0486e-07

ZeroDivisionError Traceback (most recent call last)
in
15 steps_per_epoch=steps,
16 validation_steps=stepsval,
---> 17 callbacks=callbacks
18 )

/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs)
322 'in a future version' if date is None else ('after %s' % date),
323 instructions)
--> 324 return func(*args, **kwargs)
325 return tf_decorator.make_decorator(
326 func, new_func, 'deprecated',

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
1827 use_multiprocessing=use_multiprocessing,
1828 shuffle=shuffle,
-> 1829 initial_epoch=initial_epoch)
1830
1831 @deprecation.deprecated(

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py in _method_wrapper(self, *args, **kwargs)
106 def _method_wrapper(self, *args, **kwargs):
107 if not self._in_multi_worker_mode(): # pylint: disable=protected-access
--> 108 return method(self, *args, **kwargs)
109
110 # Running inside run_distribute_coordinator already.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)
1120 use_multiprocessing=use_multiprocessing,
1121 model=self,
-> 1122 steps_per_execution=self._steps_per_execution)
1123 val_logs = self.evaluate(
1124 x=val_x,

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in init(self, x, y, sample_weight, batch_size, steps_per_epoch, initial_epoch, epochs, shuffle, class_weight, max_queue_size, workers, use_multiprocessing, model, steps_per_execution)
1115 use_multiprocessing=use_multiprocessing,
1116 distribution_strategy=ds_context.get_strategy(),
-> 1117 model=model)
1118
1119 strategy = ds_context.get_strategy()

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in init(self, x, y, sample_weights, workers, use_multiprocessing, max_queue_size, model, **kwargs)
784 # Since we have to know the dtype of the python generator when we build the
785 # dataset, we have to look at a batch to infer the structure.
--> 786 peek, x = self._peek_and_restore(x)
787 peek = self._standardize_batch(peek)
788 peek = _process_tensorlike(peek)

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in _peek_and_restore(x)
841 @staticmethod
842 def _peek_and_restore(x):
--> 843 peek = next(x)
844 return peek, itertools.chain([peek], x)
845

in make_generator(x, y, batch_size, categorical, seed)
46 random_class = rand.randrange(num_classes)
47 current_index = indexes[random_class]
---> 48 indexes[random_class] = (current_index + 1) % len(samples[random_class])
49 if current_index == 0:
50 rand.shuffle(samples[random_class])

ZeroDivisionError: integer division or modulo by zero`

this is your snippet code I modified
else: batch_y[i] = random_class batch_y_bin = np.argmax(batch_y, axis=1).astype('float32') yield ([batch_x, batch_y_bin],[batch_y,batch_y_bin])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.