Generate mask tensor according to different backend For torch and tensorflow, it will create a bool tensor For mxnet, it will create a float tensor Parameters ---------- mask: numpy ndarray input mask tensor
(mask)
| 387 | |
| 388 | |
| 389 | def generate_mask_tensor(mask): |
| 390 | """Generate mask tensor according to different backend |
| 391 | For torch and tensorflow, it will create a bool tensor |
| 392 | For mxnet, it will create a float tensor |
| 393 | Parameters |
| 394 | ---------- |
| 395 | mask: numpy ndarray |
| 396 | input mask tensor |
| 397 | """ |
| 398 | assert isinstance(mask, np.ndarray), ( |
| 399 | "input for generate_mask_tensor" "should be an numpy ndarray" |
| 400 | ) |
| 401 | if F.backend_name == "mxnet": |
| 402 | return F.tensor(mask, dtype=F.data_type_dict["float32"]) |
| 403 | else: |
| 404 | return F.tensor(mask, dtype=F.data_type_dict["bool"]) |
| 405 | |
| 406 | |
| 407 | class Subset(object): |
no outgoing calls
no test coverage detected