Reputation: 1
I found the error below when I followed the example code of 'WeightNormalization' wrapper implemented in the tensorflow-addons.
The environment is
I identify the following code doesn't work in the Colab notebook.
The code in trouble is as follows,
import tensorflow as tf
import tensorflow_addons as tfa
import numpy as np
from matplotlib import pyplot as plt
# Hyper Parameters
batch_size = 32
epochs = 10
num_classes=10
# WeightNorm ConvNet
wn_model = tf.keras.Sequential([
tfa.layers.WeightNormalization(tf.keras.layers.Conv2D(6, 5, activation='relu')),
tf.keras.layers.MaxPooling2D(2, 2),
tfa.layers.WeightNormalization(tf.keras.layers.Conv2D(16, 5, activation='relu')),
tf.keras.layers.MaxPooling2D(2, 2),
tf.keras.layers.Flatten(),
tfa.layers.WeightNormalization(tf.keras.layers.Dense(120, activation='relu')),
tfa.layers.WeightNormalization(tf.keras.layers.Dense(84, activation='relu')),
tfa.layers.WeightNormalization(tf.keras.layers.Dense(num_classes, activation='softmax')),
])
TypeError() raised for the tfa.layers.WeightNormalization()
TypeError Traceback (most recent call last)
<ipython-input-5-973cec7abd8b> in <module>
1 # WeightNorm ConvNet
2 wn_model = tf.keras.Sequential([
----> 3 tfa.layers.WeightNormalization(tf.keras.layers.Conv2D(6, 5, activation='relu')),
4 tf.keras.layers.MaxPooling2D(2, 2),
5 tfa.layers.WeightNormalization(tf.keras.layers.Conv2D(16, 5, activation='relu')),
2 frames
/usr/local/lib/python3.9/dist-packages/tensorflow_addons/layers/wrappers.py in __init__(self, layer, data_init, **kwargs)
57
58 @typechecked
---> 59 def __init__(self, layer: tf.keras.layers, data_init: bool = True, **kwargs):
60 super().__init__(layer, **kwargs)
61 self.data_init = data_init
/usr/local/lib/python3.9/dist-packages/typeguard/_functions.py in check_argument_types(memo)
111 value = memo.arguments[argname]
112 try:
--> 113 check_type_internal(value, expected_type, memo=memo)
114 except TypeCheckError as exc:
115 qualname = qualified_name(value, add_class_prefix=True)
/usr/local/lib/python3.9/dist-packages/typeguard/_checkers.py in check_type_internal(value, annotation, memo)
668 return
669
--> 670 if not isinstance(value, origin_type):
671 raise TypeCheckError(f"is not an instance of {qualified_name(origin_type)}")
672
TypeError: isinstance() arg 2 must be a type or tuple of types
I think that 'typeguard' package makes trouble, but I can't address this issue. Can you give me an answer please?
Upvotes: 0
Views: 96
Reputation: 1
You should use a typeguard version below 3.0:
pip install typeguard<3.0
Upvotes: 0