braintools.spike.bitwise_xor#
- braintools.spike.bitwise_xor(x, y)#
Perform a bitwise XOR operation on spike tensors.
This function computes the XOR operation between two spike tensors. XOR is defined as
(x OR y) AND NOT (x AND y).- Parameters:
- Returns:
The element-wise XOR of the inputs, with their broadcast shape.
- Return type:
Array|ndarray|bool|number|bool|int|float|complex|Quantity
Notes
This operation is implemented using the formula
x + y - 2 * x * y, which is equivalent to the XOR operation for binary values. Boolean inputs give a boolean result (computed with the logical functions); numeric inputs use the arithmetic formula, which keeps the dtype and stays differentiable for surrogate-gradient spikes.Examples
>>> import jax.numpy as jnp >>> import braintools >>> x = jnp.array([0, 0, 1, 1]) >>> y = jnp.array([0, 1, 0, 1]) >>> braintools.spike.bitwise_xor(x, y) Array([0, 1, 1, 0], dtype=int32)