Reputation:
#vgg16
class VGGBase(Model):
def __init__(self):
super(VGGBase,self).__init__()
self.conv1_1 = tf.keras.layers.Conv2D(3,64, kernel_size=3,padding=1,strides=1),
self.conv1_2 = tf.keras.layers.Conv2D(64,64, kernel_size=3, padding=1,strides=1),
self.pool1 = tf.keras.layers.MaxPool2D(2,2),
self.conv2_1 = tf.keras.layers.Conv2D(64,128, kernel_size=3, padding=1,strides= 1),
self.conv2_2 = tf.keras.layers.Conv2D(128,128, kernel_size=3,padding=1,strides= 1),
self.pool2 = tf.keras.layers.MaxPool2D(2,2),
def call(self,x):
x = relu(self.conv1_1(x))
x = relu(self.conv1_2(x))
x = relu(self.pool1(x))
x = relu(self.conv2_1(x))
x = relu(self.conv2_2(x))
x = relu(self.pool2(x))
This is tensrflow 2.0 and got the error of got multiple values for argument 'kernel_size"
File "/home/jake/Gits/ssd_tensorflow/model.py", line 10, in init self.conv1_1 = tf.keras.layers.Conv2D(3,64, kernel_size=3,padding=1,strides=1,input_shape=input_shape), TypeError: init() got multiple values for argument 'kernel_size'
Upvotes: 0
Views: 1488
Reputation: 77407
The call signature for Conv2D
is long, but starts with Conv2d(filter, kernel_size, ...)
. You called it with two positional arguments filling in filter
and kernel_size
and then tried to set kernel_size=3
. Since kernel_size
was already filled with a positional argument, you got the error.
Kernel size should be a two element tuple. You may have meant
self.conv1_1 = tf.keras.layers.Conv2D(64, kernel_size=(3,3), padding=1, strides=1),
As an aside, self.conv1_1
will be a 1 element tuple, which may be what you want. Otherwise, remove that ending comma.
Upvotes: 1