Improve error messages in dense_attention.py.
@@ -185,22 +185,23 @@ class BaseDenseAttention(Layer):
class_name = self.__class__.__name__
if not isinstance(inputs, list):
raise ValueError(
- '{} layer must be called on a list of inputs, namely [query, value] '
- 'or [query, value, key].'.format(class_name))
+ f'{class_name} layer must be called on a list of inputs, '
+ 'namely [query, value] or [query, value, key]. '
+ f'Received: {inputs}.')
if len(inputs) < 2 or len(inputs) > 3:
raise ValueError(
- '{} layer accepts inputs list of length 2 or 3, '
+ f'{class_name} layer accepts inputs list of length 2 or 3, '
'namely [query, value] or [query, value, key]. '
- 'Given length: {}'.format(class_name, len(inputs)))
+ f'Received length: {len(inputs)}.')
if mask:
if not isinstance(mask, list):
raise ValueError(
- '{} layer mask must be a list, '
- 'namely [query_mask, value_mask].'.format(class_name))
+ f'{class_name} layer mask must be a list, '
+ f'namely [query_mask, value_mask]. Received: {mask}.')
if len(mask) < 2 or len(mask) > len(inputs):
raise ValueError(
- '{} layer mask must be a list of length 2, namely [query_mask, '
- 'value_mask]. Given length: {}'.format(class_name, len(mask)))
+ f'{class_name} layer mask must be a list of length 2, '
+ f'namely [query_mask, value_mask]. Received length: {len(mask)}.')
def get_config(self):
config = {
