Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError #6

Open
carlotolopes opened this issue Feb 21, 2020 · 1 comment
Open

TypeError #6

carlotolopes opened this issue Feb 21, 2020 · 1 comment

Comments

@carlotolopes
Copy link

Hi! While running this part of code:

model = get_siamese_model((105, 105, 1))
model.summary()

I got this error:

TypeError Traceback (most recent call last)
in
----> 1 model = get_siamese_model((105, 105, 1))
2 model.summary()

in get_siamese_model(input_shape)
11 model = Sequential()
12 model.add(Conv2D(64, (10,10), activation='relu', input_shape=input_shape,
---> 13 kernel_initializer=initialize_weights, kernel_regularizer=l2(2e-4)))
14 model.add(MaxPooling2D())
15 model.add(Conv2D(128, (7,7), activation='relu',

~\Anaconda3\lib\site-packages\keras\engine\sequential.py in add(self, layer)
164 # and create the node connecting the current layer
165 # to the input layer we just created.
--> 166 layer(x)
167 set_inputs = True
168 else:

~\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py in symbolic_fn_wrapper(*args, **kwargs)
73 if _SYMBOLIC_SCOPE.value:
74 with get_graph().as_default():
---> 75 return func(*args, **kwargs)
76 else:
77 return func(*args, **kwargs)

~\Anaconda3\lib\site-packages\keras\engine\base_layer.py in call(self, inputs, **kwargs)
461 'You can build it manually via: '
462 'layer.build(batch_input_shape)')
--> 463 self.build(unpack_singleton(input_shapes))
464 self.built = True
465

~\Anaconda3\lib\site-packages\keras\layers\convolutional.py in build(self, input_shape)
139 name='kernel',
140 regularizer=self.kernel_regularizer,
--> 141 constraint=self.kernel_constraint)
142 if self.use_bias:
143 self.bias = self.add_weight(shape=(self.filters,),

~\Anaconda3\lib\site-packages\keras\engine\base_layer.py in add_weight(self, name, shape, dtype, initializer, regularizer, trainable, constraint)
277 if dtype is None:
278 dtype = self.dtype
--> 279 weight = K.variable(initializer(shape, dtype=dtype),
280 dtype=dtype,
281 name=name,

TypeError: initialize_weights() got an unexpected keyword argument 'dtype'

Is it related to my tf version?
My current tf version is 2.0 gpu

@aifromphytsai
Copy link

You may try this way. Rename the second argument of the following functions as "dtype":
def initialize_weights(shape, dtype=None):
return np.random.normal(loc = 0.0, scale = 1e-2, size = shape)
def initialize_bias(shape, dtype=None):
return np.random.normal(loc = 0.5, scale = 1e-2, size = shape)

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

No branches or pull requests

2 participants