votes up 7

`output_dim` should be a positive integer. Given: (param1).

Package:
Exception Class:
ValueError

Raise code

         output_dim,
               kernel_initializer='gaussian',
               scale=None,
               trainable=False,
               name=None,
               **kwargs):
    if output_dim <= 0:
      raise ValueError(
          '`output_dim` should be a positive integer. Given: {}.'.format(
              output_dim))
    if isinstance(kernel_initializer, str):
      if kernel_initializer.lower() not in _SUPPORTED_RBF_KERNEL_TYPES:
        raise ValueError(
            'Unsupported kernel type: \'{}\'. Supported kernel types: {}.'
            .format(kernel_initializer, _SUPPORTED_RBF_KERNEL_TYPES))
    if
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

Ways to fix

votes up 2 votes down

RandomFourierFeatures is a layer that projects its inputs into a random feature space. When initializing this layer the parameter output_dim should be a positive integer. If a negative integer is given it causes this error.

Reproducing the error:

from tensorflow.keras.layers.experimental import RandomFourierFeatures
random_features_layer = RandomFourierFeatures(output_dim=-500,
                                              scale=10)


Output error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-26-071d2f2887cb> in <module>()
      1 from tensorflow.keras.layers.experimental import RandomFourierFeatures
----> 2 random_features_layer = RandomFourierFeatures(output_dim=-500,scale=10)

/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/layers/kernelized.py in __init__(self, output_dim, kernel_initializer, scale, trainable, name, **kwargs)
    154       raise ValueError(
    155           '`output_dim` should be a positive integer. Given: {}.'.format(
--> 156               output_dim))
    157     if isinstance(kernel_initializer, str):
    158       if kernel_initializer.lower() not in _SUPPORTED_RBF_KERNEL_TYPES:

ValueError: `output_dim` should be a positive integer. Given: -500.


Fixed version of the code:

from tensorflow.keras.layers.experimental import RandomFourierFeatures
random_features_layer = RandomFourierFeatures(output_dim=500,
                                              scale=10)
Jul 14, 2021 kellemnegasi answer
kellemnegasi 31.6k

Add a possible fix

Please authorize to post fix