В modeling.py
, bert использует dict для хранения ожидаемого_ранка и никаких изменений позже.
Относительный код:
expected_rank_dict = {}
if isinstance(expected_rank, six.integer_types):
expected_rank_dict[expected_rank] = True
else:
for x in expected_rank:
expected_rank_dict[x] = True
actual_rank = tensor.shape.ndims
if actual_rank not in expected_rank_dict:
scope_name = tf.get_variable_scope().name
raise ValueError()
Я не понимаю причина. Может, список попроще.
Кто-нибудь может мне это объяснить? Спасибо.