Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

add pos_weight for SigmoidBinaryCrossEntropyLoss #13612

Merged
merged 25 commits into from
Mar 8, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
set N be a random number
  • Loading branch information
eureka7mt committed Jan 10, 2019
commit 100eabd26ec90da74acf28e88612b77af7098ee9
6 changes: 3 additions & 3 deletions tests/python/unittest/test_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def test_poisson_nllloss_mod():
@with_seed()
def test_bce_loss_with_pos_weight():
#Suppose it's a multi-label classification
N = 20
N = np.random.randint(5,30)
data = mx.nd.random.uniform(-1, 1, shape=(N, 20))
label = mx.nd.array(np.random.randint(2, size=(N, 5)), dtype='float32')
pos_weight = mx.nd.random.uniform(0, 10, shape=(1, 5))
Expand All @@ -442,8 +442,8 @@ def test_bce_loss_with_pos_weight():
initializer=mx.init.Xavier(magnitude=2))
assert mod.score(data_iter, eval_metric=mx.metric.Loss())[0][1] < 0.01
# Test against npy
data = mx.nd.random.uniform(-5, 5, shape=(10, 5))
label =mx.nd.array(np.random.randint(2, size=(10, 5)), dtype='float32')
data = mx.nd.random.uniform(-5, 5, shape=(N, 5))
label =mx.nd.array(np.random.randint(2, size=(N, 5)), dtype='float32')
pos_weight = mx.nd.random.uniform(0, 10, shape=(1, 5))
mx_bce_loss = Loss(data, label, pos_weight).asnumpy()
prob_npy = 1.0 / (1.0 + np.exp(-data.asnumpy()))
Expand Down