keras-team / keras-contrib

Keras community contributions
MIT License
1.58k stars 651 forks source link

Creating a resnet-152 -> exception when naming block #222

Open lostoliv opened 6 years ago

lostoliv commented 6 years ago

If you create a big resnet (resnet-152 for e.g.), _block_name_base in file "keras_contrib/applications/resnet.py" will throw an exception:

conv_name_base = 'res' + str(stage) + block + '_branch'
TypeError: cannot concatenate 'str' and 'int' objects

If block < 27, its type will be converted to 'str', and if >= 27, its type will stay 'int'.

To fix it, replace:

    if block < 27:
        block = '%c' % (block + 97)  # 97 is the ascii number for lowercase 'a'

with something like this:

    if block < 27:
        block = '%c' % (block + 97)  # 97 is the ascii number for lowercase 'a'
    else:
        block = '%d' % (block - 27)
lostoliv commented 6 years ago

Btw, it should be "26", not "27". '%c' (26 + 97) is character '{'. You want to stop at 25 with character 'z'.