pymc.pytensorf.generator#
- pymc.pytensorf.generator(gen, default=None)[source]#
Create a generator variable with possibility to set default value and new generator.
If generator is exhausted variable will produce default value if it is not None, else raises StopIteration exception that can be caught on runtime.
- Parameters:
- gen: generator that implements __next__ (py3) or next (py2) method
and yields np.arrays with same types
- default: np.array with the same type as generator produces
- Returns:
TensorVariable
It has 2 new methods - var.set_gen(gen): sets new generator - var.set_default(value): sets new default value (None erases default value)