Fix Python3 compatibility

This commit is contained in:
Makoto Matsuyama 2015-11-02 20:14:33 -08:00
parent 002a9d5d2b
commit 5964848bdf
2 changed files with 5 additions and 4 deletions

@ -308,7 +308,7 @@ class Merge(Layer):
raise Exception("Invalid type for dot_axes - should be a list.")
if len(dot_axes) != 2:
raise Exception("Invalid format for dot_axes - should contain two elements.")
if type(dot_axes[0]) not in [list, tuple] or type(dot_axes[1]) not in [list, tuple]:
if type(dot_axes[0]) not in [list, tuple, range] or type(dot_axes[1]) not in [list, tuple, range]:
raise Exception("Invalid format for dot_axes - list elements should have type 'list' or 'tuple'.")
for i in range(len(dot_axes[0])):
if shape1[dot_axes[0][i]] != shape2[dot_axes[1][i]]:

@ -128,7 +128,7 @@ class TestSequential(unittest.TestCase):
nloss = model.evaluate([X_train, X_train], y_train, verbose=0)
print(nloss)
assert(loss == nloss)
def test_merge_dot1(self):
print('Test merge: dot')
left = Sequential()
@ -146,7 +146,7 @@ class TestSequential(unittest.TestCase):
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy', optimizer='rmsprop')
def test_merge_dot2(self):
print('Test merge: dot')
left = Sequential()
@ -158,12 +158,13 @@ class TestSequential(unittest.TestCase):
right.add(Activation('relu'))
model = Sequential()
model.add(Merge([left, right], mode='dot', dot_axes=([1],[1])))
model.add(Merge([left, right], mode='dot', dot_axes=([1], [1])))
model.add(Dense(nb_class))
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy', optimizer='rmsprop')
def test_merge_concat(self):
print('Test merge: concat')
left = Sequential()