From 3f9a0292f69dcefcc6235ce8ef764c203122459e Mon Sep 17 00:00:00 2001 From: Karishma Battina <67629745+karishma-battina@users.noreply.github.com> Date: Fri, 4 Apr 2025 19:23:15 +0000 Subject: [PATCH 1/3] Add entry for pytorch bitwise not --- .../terms/bitwise-not/bitwise-not.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md diff --git a/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md b/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md new file mode 100644 index 00000000000..f37df2568be --- /dev/null +++ b/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md @@ -0,0 +1,48 @@ +--- +Title: '.bitwise_not()' +Description: 'Performs element-wise bitwise NOT operation on the input tensor, flipping each bit (0 becomes 1 and 1 becomes 0). Applicable to integer and boolean tensors.' +Subjects: + - 'AI' + - 'Data Science' +Tags: + - 'AI' + - 'Data Types' + - 'Deep Learning' + - 'Functions' +CatalogContent: + - 'intro-to-py-torch-and-neural-networks' + - 'paths/data-science' +--- + +In PyTorch, the **`.bitwise_not()`** function performs an element-wise bitwise NOT operation on the input tensor. This flips each bit of the tensor’s binary representation, turning `0` to `1` and `1` to `0`. It works for integer tensors (signed or unsigned) and boolean tensors (where it acts as a logical NOT). + +## Syntax + +```pseudo +torch.bitwise_not(input, *, out=None) +``` + +- `input`: A tensor of integer or boolean dtype. +- `out` (Optional): The output tensor to store the result. + +## Example + +The following example demonstrates the usage of the `.bitwise_not()` function: + +```py +import torch + +# Create a boolean tensor +tensor_in = torch.tensor([True, False, True]) + +# Apply bitwise NOT +result = torch.bitwise_not(tensor_in) + +print(result) +``` + +The above code produces the following output: + +```shell +tensor([False, True, False]) +``` From a21c109769fe85e10d1e5bf756611f6ad0ca1afb Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Tue, 8 Apr 2025 15:01:09 +0530 Subject: [PATCH 2/3] minor fixes --- .../terms/bitwise-not/bitwise-not.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md b/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md index f37df2568be..6a9e4f99572 100644 --- a/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md +++ b/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md @@ -14,7 +14,7 @@ CatalogContent: - 'paths/data-science' --- -In PyTorch, the **`.bitwise_not()`** function performs an element-wise bitwise NOT operation on the input tensor. This flips each bit of the tensor’s binary representation, turning `0` to `1` and `1` to `0`. It works for integer tensors (signed or unsigned) and boolean tensors (where it acts as a logical NOT). +In PyTorch, the **`.bitwise_not()`** function performs an element-wise bitwise NOT operation on the input [tensor](https://www.codecademy.com/resources/docs/pytorch/tensors). This flips each bit of the tensor’s binary representation, turning `0` to `1` and `1` to `0`. It works for integer tensors (signed or unsigned) and boolean tensors (where it acts as a logical NOT). ## Syntax @@ -22,12 +22,18 @@ In PyTorch, the **`.bitwise_not()`** function performs an element-wise bitwise N torch.bitwise_not(input, *, out=None) ``` +**Parameters:** + - `input`: A tensor of integer or boolean dtype. -- `out` (Optional): The output tensor to store the result. +- `out` (Optional): A tensor to store the output result. Must have the same shape as the input tensor. + +**Return value:** + +The `.bitwise_not()` function returns a new tensor containing the result of applying the bitwise NOT operation to each element in the input tensor. ## Example -The following example demonstrates the usage of the `.bitwise_not()` function: +The following example illustrates the usage of the `.bitwise_not()` function in PyTorch: ```py import torch From fd685e967508f69261c4ba2f292cd7eda584d8cc Mon Sep 17 00:00:00 2001 From: Sriparno Roy <89148144+Sriparno08@users.noreply.github.com> Date: Thu, 10 Apr 2025 09:00:55 +0530 Subject: [PATCH 3/3] Update bitwise-not.md --- .../tensor-operations/terms/bitwise-not/bitwise-not.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md b/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md index 6a9e4f99572..22e9d2354cf 100644 --- a/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md +++ b/content/pytorch/concepts/tensor-operations/terms/bitwise-not/bitwise-not.md @@ -1,6 +1,6 @@ --- Title: '.bitwise_not()' -Description: 'Performs element-wise bitwise NOT operation on the input tensor, flipping each bit (0 becomes 1 and 1 becomes 0). Applicable to integer and boolean tensors.' +Description: 'Performs element-wise bitwise NOT operation on the input tensor, flipping each bit (0 to 1 and 1 to 0). Applicable to integer and boolean tensors.' Subjects: - 'AI' - 'Data Science' @@ -25,7 +25,7 @@ torch.bitwise_not(input, *, out=None) **Parameters:** - `input`: A tensor of integer or boolean dtype. -- `out` (Optional): A tensor to store the output result. Must have the same shape as the input tensor. +- `out` (Optional): A tensor for storing the output result. Must have the same shape as the input tensor. **Return value:**