![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
A collection of assertion methods to compare PyTorch Tensors in tests.
Currently all assertion methods are provided by converting the tensors to numpy arrays and feeding them into an appropriate numpy.testing
method. That way, on failure, detailed information is provided as to why the test failed.
Last tested with Python 3.6.4 :: Anaconda, Inc. and PyTorch 0.4.
You can install this package using pip
:
pip install torch_testing
You can assert the equality of two torch.tensor
s like
import unittest
import torch
import torch_testing as tt
class TestSomeClass(unittest.TestCase):
def test_some_method(self):
a = torch.tensor([1, 2])
b = torch.tensor([1, 2])
tt.assert_equal(a, b)
if __name__ == '__main__':
unittest.main()
assert_equal(actual, expected, **kwargs)
Currently this assertion method is provided by converting the tensors to numpy
arrays using tensor.numpy()
and feeding them to numpy.testing.assert_equal.
assert_allclose(actual, expected, rtol=1e-07, atol=0, equal_nan=True, **kwargs)
Currently this assertion method is provided by converting the tensors to numpy
arrays using tensor.numpy()
and feeding them to numpy.testing.assert_allclose.
assert_within(tensor, min_val, max_val, rtol=0)
Ensures that all values of the given tensor
are greater than or equal to min_val
and less than or equal to max_val
. Allows to specify a relative tolerance rtol
, which behaves as in numpy.testing.assert_allclose.
NOTE: Uses assert_allclose
under the hood, hence the fail message might currently be a little confusing.
Unless noted otherwise, all commands are expected to be executed from the root directory of this repository.
To make the package available locally while making sure changes to the files are reflected immediately, run
pip install -e .
Run all tests using
python -m unittest discover tests
FAQs
A collection of assertion methods to compare PyTorch Tensors in tests
We found that torch-testing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.