You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to use the DAUs to replace standard convolutional blocks in a modified U-Net architecture but I do get these warnings and this error :
WARNING: Entity <bound method DAUConv2dTF.call of <dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a42a0f160>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, export AUTOGRAPH_VERBOSITY=10) and attach the full output. Cause: converting <bound method DAUConv2dTF.call of <dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a42a0f160>>: AssertionError: If not matching a CFG node, must be a block statement: <gast.gast.ImportFrom object at 0x1a42b4f748>
my code :
import tensorflow.compat.v1 as tf tf.logging.set_verbosity(tf.logging.ERROR) import numpy as np from tensorflow.compat.v1.keras.layers import Input, Conv2D, MaxPooling2D, Conv2DTranspose, concatenate, BatchNormalization, Activation, add from tensorflow.compat.v1.keras.models import Model, model_from_json from tensorflow.keras.activations import relu from dau_conv_tf import DAUConv2dTF
x = Conv2D(filters,(num_row, num_col), strides=strides, padding=padding, data_format ='channels_first' ,use_bias=False)(x)
x = BatchNormalization(axis=1, scale=False)(x)
if(activation == None):
return x
x = Activation(activation)(x)
return x `
out = conv2d_bn(inp, filters, 3, 3, activation='relu', padding='same')
out = add([shortcut, out])
out = Activation('relu')(out)
out = BatchNormalization(axis=1)(out)
for i in range(length-1):
shortcut = out
shortcut = conv2d_bn(shortcut, filters, 1, 1,
activation=None, padding='same')
out = dau_bn(out, filters, dau_units , max_kernel_size)
out = add([shortcut, out])
out = Activation('relu')(out)
out = BatchNormalization(axis=1)(out)
return out
model = MultiResUnet(3,128, 128)
display(model.summary())
`
Now the error I get :
TypeError Traceback (most recent call last)
in
----> 1 model = MultiResUnet(3,128, 128)
2 display(model.summary())
in MultiResUnet(n_channels, height, width)
54 conv10 = conv2d_bn(mresblock9, 1, 1, 1, activation='sigmoid')
55
---> 56 model = Model(inputs=[inputs], outputs=[conv10])
57
58 return model
~/miniconda3/envs/MastersThenv/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in init(self, *args, **kwargs)
127
128 def init(self, *args, **kwargs):
--> 129 super(Model, self).init(*args, **kwargs)
130 # initializing _distribution_strategy here since it is possible to call
131 # predict on a model without compiling it.
~/miniconda3/envs/MastersThenv/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py in init(self, *args, **kwargs)
165 self._init_subclassed_network(**kwargs)
166
--> 167 tf_utils.assert_no_legacy_layers(self.layers)
168
169 # Several Network methods have "no_automatic_dependency_tracking"
~/miniconda3/envs/MastersThenv/lib/python3.6/site-packages/tensorflow/python/keras/utils/tf_utils.py in assert_no_legacy_layers(layers)
397 'classes), please use the tf.keras.layers implementation instead. '
398 '(Or, if writing custom layers, subclass from tf.keras.layers rather '
--> 399 'than tf.layers)'.format(layer_str))
400
401
TypeError: The following are legacy tf.layers.Layers:
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a42a0f160>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a42ac44e0>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a42d1f9e8>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a43aaf048>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a43b6d358>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a43ce27f0>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a448cb0b8>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a44a9ccc0>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a44b00860>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a453f3400>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a454a37f0>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4554fd30>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a45ce3e48>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a45ebf518>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a444bc0b8>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4665a588>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4ad5b518>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4adffac8>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4511c668>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4b3f5710>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4b4a5ac8>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a44324048>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a45e96b70>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a445fe3c8>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4323aa58>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4bb59898>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4bd356d8>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a435126d8>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4bd976a0>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a437f65c0>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4c2bc2e8>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4c375668>
<dau_conv_tf.dau_conv.DAUConv2dTF object at 0x1a4c425c88>
To use keras as a framework (for instance using the Network, Model, or Sequential classes), please use the tf.keras.layers implementation instead. (Or, if writing custom layers, subclass from tf.keras.layers rather than tf.layers)
and my tf.keras.version == 2.2.4-tf
running on mac os HighSierra
Any help would be highly appreciated,
cheers, H
The text was updated successfully, but these errors were encountered:
sorry for late reply as I wasn't able to find time before.
Do you actually get an error that it cannot go further? It appears that there seems to be some legacy issue, as I have created layers from examples of TensorFlow v1 based on tf.contrib.layer.conv2d(). It seams this is not compatible with your version of Keras layers. You will have to modify the base inheritance class for DAUConv2dTF to make ti work your version of Keras.
Hi there,
I try to use the DAUs to replace standard convolutional blocks in a modified U-Net architecture but I do get these warnings and this error :
my code :
import tensorflow.compat.v1 as tf tf.logging.set_verbosity(tf.logging.ERROR) import numpy as np from tensorflow.compat.v1.keras.layers import Input, Conv2D, MaxPooling2D, Conv2DTranspose, concatenate, BatchNormalization, Activation, add from tensorflow.compat.v1.keras.models import Model, model_from_json from tensorflow.keras.activations import relu from dau_conv_tf import DAUConv2dTF
` def dau_bn(x, filters, dau_units, max_kernel_size):
` def conv2d_bn(x, filters ,num_row,num_col, padding = "same", strides = (1,1), activation = 'relu'):
`def trans_conv2d(x, filters, num_row, num_col, padding='same', strides=(2, 2), name=None):
` def MultiResBlock(dau_units,max_kernel_size ,U,inp, alpha = 1.67):
`def ResPath(dau_units, max_kernel_size,filters, length, inp):
shortcut = inp
shortcut = conv2d_bn(shortcut, filters, 1, 1,
activation=None, padding='same')
def MultiResUnet(n_channels,height, width):
model = MultiResUnet(3,128, 128)
display(model.summary())
`
and my tf.keras.version == 2.2.4-tf
running on mac os HighSierra
Any help would be highly appreciated,
cheers, H
The text was updated successfully, but these errors were encountered: