-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #541 from gizatechxyz/develop
Merge develop into main
- Loading branch information
Showing
606 changed files
with
28,628 additions
and
1,222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
scarb 2.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
docs/framework/operators/machine-learning/linear-classifier/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Linear Classifier | ||
|
||
`LinearClassifierTrait` provides a trait definition for linear classification problem. | ||
|
||
```rust | ||
use orion::operators::ml::LinearClassificationTrait; | ||
``` | ||
|
||
### Data types | ||
|
||
Orion supports currently only fixed point data types for `LinearClassificationTrait`. | ||
|
||
| Data type | dtype | | ||
| -------------------- | ------------------------------------------------------------- | | ||
| Fixed point (signed) | `LinearClassifierTrait<FP8x23 \| FP16x16 \| FP64x64 \| FP32x32>` | | ||
|
||
|
||
*** | ||
|
||
| function | description | | ||
| --- | --- | | ||
| [`linear_classifier.predict`](linear_classifier.predict.md) | Performs the linear classification. | | ||
|
100 changes: 100 additions & 0 deletions
100
...ework/operators/machine-learning/linear-classifier/linear_classifier.predict.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# LinearClassifierTrait::predict | ||
|
||
```rust | ||
fn predict(ref self: LinearClassifier<T>, X: Tensor<T>) -> Tensor<T>; | ||
``` | ||
|
||
Linear Classifier. Performs the linear classification. | ||
|
||
## Args | ||
|
||
* `self`: LinearClassifier<T> - A LinearClassifier object. | ||
* `X`: Input 2D tensor. | ||
|
||
## Returns | ||
|
||
* Tensor<T> containing the linear classification evaluation of the input X. | ||
|
||
## Type Constraints | ||
|
||
`LinearClassifier` and `X` must be fixed points | ||
|
||
## Examples | ||
|
||
```rust | ||
use orion::numbers::FP16x16; | ||
use orion::operators::tensor::{Tensor, TensorTrait, FP16x16Tensor, U32Tensor}; | ||
|
||
use orion::operators::ml::linear::linear_classifier::{ | ||
LinearClassifierTrait, POST_TRANSFORM, LinearClassifier | ||
}; | ||
|
||
fn linear_classifier_helper( | ||
post_transform: POST_TRANSFORM | ||
) -> (LinearClassifier<FP16x16>, Tensor<FP16x16>) { | ||
|
||
let classlabels: Span<usize> = array![0, 1, 2].span(); | ||
let classlabels = Option::Some(classlabels); | ||
|
||
let classlabels_strings: Option<Span<FP16x16>> = Option::None; | ||
|
||
let coefficients: Span<FP16x16> = array![ | ||
FP16x16 { mag: 38011, sign: true }, | ||
FP16x16 { mag: 19005, sign: true }, | ||
FP16x16 { mag: 5898, sign: true }, | ||
FP16x16 { mag: 38011, sign: false }, | ||
FP16x16 { mag: 19005, sign: false }, | ||
FP16x16 { mag: 5898, sign: false }, | ||
] | ||
.span(); | ||
|
||
let intercepts: Span<FP16x16> = array![ | ||
FP16x16 { mag: 176947, sign: false }, | ||
FP16x16 { mag: 176947, sign: true }, | ||
FP16x16 { mag: 32768, sign: false }, | ||
] | ||
.span(); | ||
let intercepts = Option::Some(intercepts); | ||
|
||
let multi_class: usize = 0; | ||
|
||
let mut classifier: LinearClassifier<FP16x16> = LinearClassifier { | ||
classlabels, | ||
coefficients, | ||
intercepts, | ||
multi_class, | ||
post_transform | ||
}; | ||
|
||
let mut X: Tensor<FP16x16> = TensorTrait::new( | ||
array![3, 2].span(), | ||
array![ | ||
FP16x16 { mag: 0, sign: false }, | ||
FP16x16 { mag: 65536, sign: false }, | ||
FP16x16 { mag: 131072, sign: false }, | ||
FP16x16 { mag: 196608, sign: false }, | ||
FP16x16 { mag: 262144, sign: false }, | ||
FP16x16 { mag: 327680, sign: false }, | ||
] | ||
.span() | ||
); | ||
|
||
(classifier, X) | ||
} | ||
|
||
fn linear_classifier_multi_softmax() -> (Span<usize>, Tensor<FP16x16>) { | ||
let (mut classifier, X) = linear_classifier_helper(POST_TRANSFORM::SOFTMAX); | ||
|
||
let (labels, mut scores) = LinearClassifierTrait::predict(ref classifier, X); | ||
|
||
(labels, scores) | ||
} | ||
|
||
>>> | ||
([0, 2, 2], | ||
[ | ||
[0.852656, 0.009192, 0.138152], | ||
[0.318722, 0.05216, 0.629118], | ||
[0.036323, 0.090237, 0.87344] | ||
]) | ||
``` |
23 changes: 23 additions & 0 deletions
23
docs/framework/operators/machine-learning/svm-regressor/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SVM Regressor | ||
|
||
`SVMRegressorTrait` provides a trait definition for svm regression problem. | ||
|
||
```rust | ||
use orion::operators::ml::SVMRegressorTrait; | ||
``` | ||
|
||
### Data types | ||
|
||
Orion supports currently only fixed point data types for `SVMRegressorTrait`. | ||
|
||
| Data type | dtype | | ||
| -------------------- | ------------------------------------------------------------- | | ||
| Fixed point (signed) | `SVMRegressorTrait<FP8x23 \| FP16x16 \| FP64x64 \| FP32x32>` | | ||
|
||
|
||
*** | ||
|
||
| function | description | | ||
| --- | --- | | ||
| [`svm_regressor.predict`](svm_regressor.predict.md) | Returns the regressed values for each input in N. | | ||
|
Oops, something went wrong.