Skip to content

Commit

Permalink
Merge pull request #52 from FL03/v0.1.13-dev
Browse files Browse the repository at this point in the history
v0.1.13 Dev
  • Loading branch information
FL03 authored May 10, 2024
2 parents bd3ad56 + ba78e14 commit 6d8c663
Show file tree
Hide file tree
Showing 92 changed files with 2,242 additions and 1,147 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ members = [
"derive",
"macros",
"models/linear",
"models/gnn"
"models/gnn",
"models/kan",
]

resolver = "2"
Expand Down
46 changes: 38 additions & 8 deletions concision/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ gnn = [
"dep:concision-gnn",
]

kan = [
"dep:concision-kan",
]

linear = [
"dep:concision-linear"
]
Expand All @@ -60,46 +64,67 @@ macros = [
"dep:concision-macros"
]



models = [
"linear",
"gnn",
"kan",
"linear",
]

rand = [
"concision-core/rand",
"concision-data/rand",
"concision-linear/rand",

"concision-gnn/rand",
"concision-kan/rand",
"concision-linear/rand",
]

serde = [
"concision-core/serde",
"concision-data/serde",
"concision-linear/serde",
"concision-gnn/serde",
"concision-kan/serde",
"concision-linear/serde",
]

std = [
"concision-core/std",
"concision-data/std",
"concision-linear/std",
"concision-gnn/std",
"concision-kan/std",
"concision-linear/std",
]

tracing = [
"concision-core/tracing",
"concision-data/tracing",
"concision-linear/tracing",
"concision-gnn/tracing",
"concision-kan/tracing",
"concision-linear/tracing",
]

wasm = [
"concision-core/wasm",
"concision-data/wasm",
"concision-gnn/wasm",
"concision-kan/wasm",
"concision-linear/wasm",
]

wasi = [
"concision-core/wasi",
"concision-data/wasi",
"concision-gnn/wasi",
"concision-kan/wasi",
"concision-linear/wasi",
]

blas = [
"concision-core/blas",
"concision-data/blas",
"concision-linear/blas",
"concision-gnn/blas",
"concision-kan/blas",
"concision-linear/blas",
]

intel-mkl-system = [
Expand Down Expand Up @@ -164,6 +189,11 @@ optional = true
path = "../models/gnn"
version = "0.1.13"

[dependencies.concision-kan]
optional = true
path = "../models/kan"
version = "0.1.13"

[dependencies.concision-linear]
optional = true
path = "../models/linear"
Expand Down
20 changes: 17 additions & 3 deletions concision/examples/basic.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
/*
Appellation: basic <example>
Contrib: FL03 <jo3mccain@icloud.com>
*/
extern crate concision as cnc;
extern crate ndarray as nd;

use cnc::ops::pad;

use ndarray::prelude::*;
use nd::prelude::Array;

fn main() -> anyhow::Result<()> {
println!("Welcome to concision!");
let samples = 8;
let _samples = 8;

let a = core::any::TypeId::of::<Biased>();
let b = core::any::TypeId::of::<Unbiased>();
assert_ne!(a, b);
println!("{:?}\n{:?}", a, b);
Ok(())
}
pub enum Biased {}
pub enum Unbiased {}

pub fn sample_padding(samples: usize) -> anyhow::Result<()> {
let arr = Array::range(0.0, (samples * samples) as f64, 1.0).into_shape((samples, samples))?;
let padded = pad(&arr, &[[0, 8]], 0.0.into());
println!("{:?}", &padded);
Expand Down
19 changes: 9 additions & 10 deletions concision/examples/linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*/
extern crate concision as cnc;

use cnc::func::Sigmoid;
use cnc::linear::{Config, Features, Linear};
use cnc::{linarr, Predict, Result};
use cnc::linear::{Biased, Linear};
use cnc::prelude::{linarr, Result, Sigmoid};
use ndarray::Ix2;

fn tracing() {
use tracing::Level;
Expand All @@ -25,16 +25,15 @@ fn main() -> Result<()> {
tracing();
tracing::info!("Starting linear model example");

let (samples, dmodel, features) = (20, 5, 3);
let shape = Features::new(features, dmodel);
let config = Config::new("example", shape).biased();
let data = linarr::<f64, ndarray::Ix2>((samples, dmodel)).unwrap();
let (samples, d_in, d_out) = (20, 5, 3);
let data = linarr::<f64, Ix2>((samples, d_in)).unwrap();

let model: Linear<f64> = Linear::std(config).uniform();
let model: Linear<Biased, f64, Ix2> = Linear::from_features(d_in, d_out).uniform();
assert!(model.is_biased());

let y = model.activate(&data, Sigmoid::sigmoid).unwrap();
assert_eq!(y.dim(), (samples, features));
println!("Predictions: {:?}", y);
assert_eq!(y.dim(), (samples, d_out));
println!("Predictions:\n{:?}", &y);

Ok(())
}
10 changes: 10 additions & 0 deletions concision/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@
//!
//! Concision aims to be a complete machine learning library written in pure Rust.
//!
#![allow(unused_imports)]
#![crate_name = "concision"]

#[doc(inline)]
pub use concision_core::*;
#[cfg(feature = "data")]
#[doc(inline)]
pub use concision_data as data;
#[cfg(feature = "derive")]
pub use concision_derive::*;
#[cfg(feature = "gnn")]
#[doc(inline)]
pub use concision_gnn as gnn;
#[cfg(feature = "kan")]
#[doc(inline)]
pub use concision_kan as kan;
#[cfg(feature = "linear")]
#[doc(inline)]
pub use concision_linear as linear;
#[cfg(feature = "macros")]
pub use concision_macros::*;
Expand All @@ -28,6 +36,8 @@ pub mod prelude {
pub use concision_derive::*;
#[cfg(feature = "gnn")]
pub use concision_gnn::prelude::*;
#[cfg(feature = "kan")]
pub use concision_kan::prelude::*;
#[cfg(feature = "linear")]
pub use concision_linear::prelude::*;
#[cfg(feature = "macros")]
Expand Down
89 changes: 71 additions & 18 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[package]
authors.workspace = true
build = "build.rs"
categories.workspace = true
description.workspace = true
edition.workspace = true
Expand All @@ -21,9 +22,16 @@ full = [
"approx",
"rand",
"serde",
"tracing",
]

alloc = []
# [FF] Dependencies
alloc = [
"num/alloc",
"rand?/alloc",
"rand_distr?/alloc",
"serde?/alloc",
]

approx = [
"dep:approx",
Expand All @@ -36,61 +44,106 @@ blas = [

rand = [
"dep:rand",
"dep:rand_distr",
"dep:ndarray-rand",
"rand-ext",
]

rand-ext = [
"num/rand",
"uuid/rng",
"uuid/v4",
]

serde = [
"dep:serde",
"serde-ext"
rng_std = [
"rand?/std",
"rand?/std_rng",
]

serde-ext = [
serde = [
"serde-1",
"ndarray/serde-1",
"num/serde",
"rand?/serde1",
"rand_distr?/serde1",
"uuid/serde"
]

serde-1 = [
"dep:serde"
]

tracing = [
"dep:tracing"
]

# ********* [FF] Environments *********
std = [
"alloc",
"ndarray/std",
"num/std",
"rand/std",
"rand/std_rng",
"rng_std",
"serde/std",
"strum/std",
"uuid/std"
]

tracing = [
"dep:tracing"
]
wasm = []

wasi = []

[lib]
bench = false
crate-type = ["lib"]
doctest = false
test = true

[[test]]
name = "fft"
required-features = ["approx"]

[build-dependencies]

[dependencies]
approx = { optional = true, version = "0.5" }
ndarray.workspace = true
ndarray-rand = { optional = true, version = "0.14" }
num.workspace = true
rand = { default-features = false, optional = true, version = "0.8" }
rand_distr = { default-features = false, optional = true, version = "0.4" }
serde = { default-features = false, features = ["derive"], optional = true, version = "1" }
smart-default.workspace = true
strum.workspace = true
tracing = { optional = true, version = "0.1" }
uuid = { features = ["v4", "v7"], version = "1" }

[dependencies.approx]
optional = true
version = "0.5"

[dependencies.ndarray-rand]
optional = true
version = "0.14"

[dependencies.rand]
default-features = false
optional = true
version = "0.8"

[dependencies.rand_distr]
default-features = false
optional = true
version = "0.4"

[dependencies.serde]
default-features = false
features = ["derive"]
optional = true
version = "1"

[dependencies.tracing]
optional = true
version = "0.1"

[dependencies.uuid]
default-features = false
features = ["v5", "v8"]
version = "1"

[dev-dependencies]
approx = "0.5"
lazy_static = "1"

[package.metadata.docs.rs]
Expand Down
8 changes: 8 additions & 0 deletions core/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Appellation: build <build>
Contrib: FL03 <jo3mccain@icloud.com>
*/

fn main() {
println!("cargo::rustc-check-cfg=cfg(no_std)");
}
Loading

0 comments on commit 6d8c663

Please sign in to comment.