Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeili committed Dec 20, 2020
1 parent fad8873 commit 9ed0420
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions deepchem/models/tests/test_losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ def test_sparse_softmax_cross_entropy_tf(self):
expected = [-np.log(softmax[0, 1]), -np.log(softmax[1, 0])]
assert np.allclose(expected, result)

labels = tf.constant([[1], [0]])
result = loss._compute_tf_loss(outputs, labels).numpy()
softmax = np.exp(y) / np.expand_dims(np.sum(np.exp(y), axis=1), 1)
expected = [-np.log(softmax[0, 1]), -np.log(softmax[1, 0])]
assert np.allclose(expected, result)

@unittest.skipIf(not has_pytorch, 'PyTorch is not installed')
def test_sparse_softmax_cross_entropy_pytorch(self):
"""Test SparseSoftmaxCrossEntropy."""
Expand Down

0 comments on commit 9ed0420

Please sign in to comment.