Skip to content

Commit

Permalink
Fix batch_dot of CNTK when axes=None (keras-team#9921)
Browse files Browse the repository at this point in the history
  • Loading branch information
taehoonlee authored and Vijayabhaskar96 committed May 1, 2018
1 parent 3b9133d commit 30bf315
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion keras/backend/cntk_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,11 @@ def batch_dot(x, y, axes=None):
axes = [len(x_shape) - 1, len(y_shape) - 2]

if len(x_shape) == 2 and len(y_shape) == 2:
return sum(x * y, axis=1, keepdims=True)
if axes[0] == axes[1]:
result = sum(x * y, axis=axes[0], keepdims=True)
return result if axes[0] == 1 else transpose(result)
else:
return sum(x * transpose(y), axis=axes[0], keepdims=True)
else:
if len(y_shape) == 2:
y = expand_dims(y)
Expand Down

0 comments on commit 30bf315

Please sign in to comment.