Check that `call` has only one positional arg.
(self, method_name)
| 1420 | callbacks=callbacks) |
| 1421 | |
| 1422 | def _check_call_args(self, method_name): |
| 1423 | """Check that `call` has only one positional arg.""" |
| 1424 | # Always allow first arg, regardless of arg name. |
| 1425 | fullargspec = tf_inspect.getfullargspec(self.call) |
| 1426 | if fullargspec.defaults: |
| 1427 | positional_args = fullargspec.args[:-len(fullargspec.defaults)] |
| 1428 | else: |
| 1429 | positional_args = fullargspec.args |
| 1430 | if 'training' in positional_args: |
| 1431 | positional_args.remove('training') |
| 1432 | |
| 1433 | # self and first arg can be positional. |
| 1434 | if len(positional_args) > 2: |
| 1435 | extra_args = positional_args[2:] |
| 1436 | raise ValueError( |
| 1437 | 'Models passed to `' + method_name + '` can only have `training` ' |
| 1438 | 'and the first argument in `call` as positional arguments, ' |
| 1439 | 'found: ' + str(extra_args) + '.') |
| 1440 | |
| 1441 | def _set_optimizer(self, optimizer): |
| 1442 | """Sets self.optimizer. |