1712 | def random(self, array_or_shape): |
1713 | """ |
1714 | Generate a random sample with the same type as the layer. |
1715 | For an Exponential layer, draws from the exponential distribution |
1716 | with the rate determined by the params attribute. |
1717 | |
1718 | Used for generating initial configurations for Monte Carlo runs. |
1719 | |
1720 | Args: |
1721 | array_or_shape (array or shape tuple): |
1722 | If tuple, then this is taken to be the shape. |
1723 | If array, then its shape is used. |
1724 | |
1725 | Returns: |
1726 | tensor: Random sample with desired shape. |
1727 | |
1728 | """ |
1729 | try: |
1730 | shape = be.shape(array_or_shape) |
1731 | except Exception: |
1732 | shape = array_or_shape |
1733 | |
1734 | r = self.rand(shape) |
1735 | return be.divide(self.params.loc, -be.log(r)) |