Open abhimasand opened 3 years ago
Got TypeError: The added layer must be an instance of class Layer. Found: <nfnets_keras.nfnet_layers.WSConv2D object at 0x0000027588029108> when trying to use NFNet F0.
TypeError Traceback (most recent call last) <ipython-input-5-7c7f86819ecc> in <module> 5 model_path = model_path + 'best_model_NFNet_F0-{epoch:02d}-{val_loss:.6f}.hdf5' 6 ----> 7 model = NFNetF0(include_top = True, num_classes = 7) 8 model.compile( SGD_AGC(lr=1e-3), loss='categorical_crossentropy' ) 9 #model.compile('adam', 'categorical_crossentropy') ~\AppData\Local\Continuum\anaconda3\lib\site-packages\nfnets_keras\nfnet.py in NFNetF0(num_classes, width, se_ratio, alpha, stochdepth_rate, drop_rate, activation, fc_init, final_conv_mult, final_conv_ch, use_two_convs, name, include_top) 204 205 --> 206 def NFNetF0(num_classes=None, width = 1.0, se_ratio = 0.5, alpha = 0.2, stochdepth_rate = 0.1, drop_rate = None, activation = 'gelu', fc_init = None, final_conv_mult = 2, final_conv_ch = None, use_two_convs = True, name = 'NFNet', include_top = True): return NFNet(num_classes=num_classes, variant = 'F0', width = width, se_ratio = se_ratio, alpha = alpha, stochdepth_rate = stochdepth_rate, drop_rate = drop_rate, activation = activation, fc_init = fc_init, final_conv_mult = final_conv_mult, final_conv_ch = final_conv_ch, use_two_convs = use_two_convs, name = name, include_top = include_top) 207 def NFNetF1(num_classes=None, width = 1.0, se_ratio = 0.5, alpha = 0.2, stochdepth_rate = 0.1, drop_rate = None, activation = 'gelu', fc_init = None, final_conv_mult = 2, final_conv_ch = None, use_two_convs = True, name = 'NFNet', include_top = True): return NFNet(num_classes=num_classes, variant = 'F1', width = width, se_ratio = se_ratio, alpha = alpha, stochdepth_rate = stochdepth_rate, drop_rate = drop_rate, activation = activation, fc_init = fc_init, final_conv_mult = final_conv_mult, final_conv_ch = final_conv_ch, use_two_convs = use_two_convs, name = name, include_top = include_top) 208 def NFNetF2(num_classes=None, width = 1.0, se_ratio = 0.5, alpha = 0.2, stochdepth_rate = 0.1, drop_rate = None, activation = 'gelu', fc_init = None, final_conv_mult = 2, final_conv_ch = None, use_two_convs = True, name = 'NFNet', include_top = True): return NFNet(num_classes=num_classes, variant = 'F2', width = width, se_ratio = se_ratio, alpha = alpha, stochdepth_rate = stochdepth_rate, drop_rate = drop_rate, activation = activation, fc_init = fc_init, final_conv_mult = final_conv_mult, final_conv_ch = final_conv_ch, use_two_convs = use_two_convs, name = name, include_top = include_top) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\nfnets_keras\nfnet.py in __init__(self, num_classes, variant, width, se_ratio, alpha, stochdepth_rate, drop_rate, activation, fc_init, final_conv_mult, final_conv_ch, use_two_convs, name, include_top) 108 self.which_conv = WSConv2D 109 ch = self.width_pattern[0] // 2 --> 110 self.stem = tf.keras.Sequential([self.which_conv(16, kernel_size = 3, strides = 2, padding = 'same', name = 'stem_conv0'), self.activation, self.which_conv(32, kernel_size = 3, strides = 1, padding = 'same', name = 'stem_conv1'), self.activation, self.which_conv(64, kernel_size = 3, strides = 1, padding = 'same', name = 'stem_conv2'), self.activation, self.which_conv(ch, kernel_size = 3, strides = 2, padding = 'same', name = 'stem_conv3'), ]) 111 self.blocks = [] 112 expected_std = 1.0 ~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs) 515 self._self_setattr_tracking = False # pylint: disable=protected-access 516 try: --> 517 result = method(self, *args, **kwargs) 518 finally: 519 self._self_setattr_tracking = previous_value # pylint: disable=protected-access ~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\engine\sequential.py in __init__(self, layers, name) 142 layers = [layers] 143 for layer in layers: --> 144 self.add(layer) 145 146 @property ~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs) 515 self._self_setattr_tracking = False # pylint: disable=protected-access 516 try: --> 517 result = method(self, *args, **kwargs) 518 finally: 519 self._self_setattr_tracking = previous_value # pylint: disable=protected-access ~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\engine\sequential.py in add(self, layer) 182 raise TypeError('The added layer must be ' 183 'an instance of class Layer. ' --> 184 'Found: ' + str(layer)) 185 186 tf_utils.assert_no_legacy_layers([layer]) TypeError: The added layer must be an instance of class Layer. Found: <nfnets_keras.nfnet_layers.WSConv2D object at 0x0000027588029108>```
Got TypeError: The added layer must be an instance of class Layer. Found: <nfnets_keras.nfnet_layers.WSConv2D object at 0x0000027588029108> when trying to use NFNet F0.