compare_tensors ¶
CLI module for comparing tensors.
Functions:
-
compare_tensors
–Compare tensors.
-
compare_tensors_and_save
–Compare tensors and save the results to a CSV file.
-
cosine_similarity
–Compute the cosine similarity between two tensors.
-
discrete_compare
–Compute the discrete comparison between two tensors.
compare_tensors ¶
compare_tensors(
tensor1: dict[str, Tensor],
tensor2: dict[str, Tensor],
mode: str = "cosine_similarity",
) -> dict[str, Tensor]
Compare tensors.
Parameters:
-
tensor1
(dict[str, Tensor]
) –First tensor.
-
tensor2
(dict[str, Tensor]
) –Second tensor.
-
mode
(str
, default:'cosine_similarity'
) –Mode to use for comparison.
Returns:
Source code in src/stimulus/cli/compare_tensors.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
compare_tensors_and_save ¶
compare_tensors_and_save(
tensor_paths: list[str],
output_logs: str,
mode: str = "cosine_similarity",
) -> None
Compare tensors and save the results to a CSV file.
Parameters:
-
tensor_paths
(list[str]
) –List of paths to the tensors to compare.
-
output_logs
(str
) –Path to save the logs.
-
mode
(str
, default:'cosine_similarity'
) –Mode to use for comparison.
Source code in src/stimulus/cli/compare_tensors.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
cosine_similarity ¶
cosine_similarity(
tensor1: Tensor, tensor2: Tensor
) -> Tensor
Compute the cosine similarity between two tensors.
Parameters:
-
tensor1
(Tensor
) –First tensor.
-
tensor2
(Tensor
) –Second tensor.
Returns:
-
Tensor
–The cosine similarity between the two tensors.
Source code in src/stimulus/cli/compare_tensors.py
13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
discrete_compare ¶
discrete_compare(
tensor1: Tensor, tensor2: Tensor, threshold: float = 0.0
) -> Tensor
Compute the discrete comparison between two tensors.
Parameters:
-
tensor1
(Tensor
) –First tensor.
-
tensor2
(Tensor
) –Second tensor.
Returns:
-
Tensor
–The discrete comparison between the two tensors.
Source code in src/stimulus/cli/compare_tensors.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|