Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Typesec error: SineReLU advaced activation functions #565

Open
sleepingcat4 opened this issue Oct 21, 2022 · 0 comments
Open

Typesec error: SineReLU advaced activation functions #565

sleepingcat4 opened this issue Oct 21, 2022 · 0 comments

Comments

@sleepingcat4
Copy link

SineReLU gone rough in Sequential Method after being called through string alias method

Previously, I had called SineReLU function in subclass model building method using string alias through get_custom_objects(), Unfortunately, BatchNormalization function failed in that method producing an interesting error of invalid tesnor rank.

Don't want to be carried out! I then swtiched to something called Sequential method, yada! Our favourite proven way!! But, this time, it shows a typesec error with the SineReLU function which is totally weird. Because, I have improted and run the functional call in previous cell and all works perfectly fine except while I call the function within the core model architecture.

I am really adamant at this point, to get SineReLU function to work so much, I will even write custom code in the keras-contrib library if that what takes to fix this error. (I could get away with Swish function but I won't)

## My Code:

Importing libraries

import tensorflow as tf
import numpy as np
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.layers import Conv2D, Dense, Flatten, MaxPool2D, Input, Dropout, CategoryEncoding, BatchNormalization, ReLU
from keras_contrib.layers.advanced_activations.sinerelu import SineReLU
from tensorflow.keras import Model
from keras.utils.generic_utils import get_custom_objects
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from keras.layers import Activation
from keras.layers.pooling.max_pooling2d import MaxPooling2D

# Calling custom functions
get_custom_objects().update({'SineReLU': Activation(SineReLU)})

Error Log:

    891         3, "Failed to convert %r to tensor: %s" % (type(value).__name__, e))
    892 
--> 893   raise TypeError(f"Could not build a TypeSpec for {value} of "
    894                   f"unsupported type {type(value)}.")
    895 

TypeError: Could not build a TypeSpec for <keras_contrib.layers.advanced_activations.sinerelu.SineReLU object at 0x7f4d5c575ad0> of unsupported type <class 'keras_contrib.layers.advanced_activations.sinerelu.SineReLU'>.

I will really appreciate if anyone can help me fix this error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant