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
😲 Agile task management is now easier than calling a taxi. #Tracklify
🙏 Scream for help to Ukraine
Today, 2nd July 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

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 30.0k

Add a possible fix

Please authorize to post fix