(batch_size: int, log_softmax: bool = False)
| 454 | |
| 455 | |
| 456 | def do_test_softmax(batch_size: int, log_softmax: bool = False): |
| 457 | num_dims = random(low=1, high=5).to(int) |
| 458 | m = torch.nn.Softmax(dim=random(low=0, high=num_dims).to(int) | nothing()) |
| 459 | if log_softmax: |
| 460 | m = torch.nn.LogSoftmax(dim=random(low=0, high=num_dims).to(int) | nothing()) |
| 461 | m.train(random()) |
| 462 | device = random_device() |
| 463 | m.to(device) |
| 464 | x = ( |
| 465 | random_tensor(ndim=num_dims).to(device) |
| 466 | if batch_size < 0 |
| 467 | else random_tensor(ndim=num_dims, dim0=batch_size).to(device) |
| 468 | ) |
| 469 | y = m(x) |
| 470 | return y |
| 471 | |
| 472 | |
| 473 | @flow.unittest.skip_unless_1n1d() |
no test coverage detected