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

model.fit() got error "TypeError: add_weight() got multiple values for argument 'name'" #120

Open
pnovenaa opened this issue Sep 27, 2019 · 1 comment

Comments

@pnovenaa
Copy link

pnovenaa commented Sep 27, 2019

I'm using anago 1.0.8 on jupyter notebook
got this error

`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
----> 1 model.fit(x_train, y_train, epochs=15)

/home/xxx/.conda/envs/xxx/lib/python3.7/site-packages/anago/wrapper.py in fit(self, x_train, y_train, x_valid, y_valid, epochs, batch_size, verbose, callbacks, shuffle)
78 use_char=self.use_char,
79 use_crf=self.use_crf)
---> 80 model, loss = model.build()
81 model.compile(loss=loss, optimizer=self.optimizer)
82

/home/xxx/.conda/envs/xxx/lib/python3.7/site-packages/anago/models.py in build(self)
113 crf = CRF(self._num_labels, sparse_target=False)
114 loss = crf.loss_function
--> 115 pred = crf(z)
116 else:
117 loss = 'categorical_crossentropy'

/home/xxx/.conda/envs/xxx/lib/python3.7/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

/home/xxx/.conda/envs/xxx/lib/python3.7/site-packages/anago/layers.py in build(self, input_shape)
180 initializer=self.kernel_initializer,
181 regularizer=self.kernel_regularizer,
--> 182 constraint=self.kernel_constraint)
183 self.chain_kernel = self.add_weight((self.units, self.units),
184 name='chain_kernel',

TypeError: add_weight() got multiple values for argument 'name'
`

@pnovenaa pnovenaa changed the title mode.fit got error "TypeError: add_weight() got multiple values for argument 'name'" model.fit() got error "TypeError: add_weight() got multiple values for argument 'name'" Sep 27, 2019
@G-bgyl
Copy link

G-bgyl commented Oct 21, 2019

Met the same problem.

Update--
Able to detect the issue.
It is because the use of new version of Keras. The requirements for anago is keras 2.2.0.

Solution--
Try to create a new virtual environment and install the Anago requirements.txt .

And btw, Torch is not compatible with windows, so if you are on a windows system, try to forget about the last required package allennlp, which needs torch as dependency. (Delete it from the requirements.txt is what I did).

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