Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to ndarray 0.16 #371

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ serde = ["serde_crate", "ndarray/serde"]
[dependencies]
num-traits = "0.2"
rand = { version = "0.8", features = ["small_rng"] }
approx = "0.4"
approx = "0.5"

ndarray = { version = "0.15", features = ["approx"] }
ndarray-linalg = { version = "0.16", optional = true }
sprs = { version = "=0.11.1", default-features = false }
ndarray = { version = "0.16", features = ["approx"] }
ndarray-linalg = { version = "0.17", optional = true }
sprs = { version = "0.11", default-features = false }

thiserror = "1.0"

Expand All @@ -56,7 +56,7 @@ default-features = false
features = ["std", "derive"]

[dev-dependencies]
ndarray-rand = "0.14"
ndarray-rand = "0.15"
linfa-datasets = { path = "datasets", features = [
"winequality",
"iris",
Expand Down
10 changes: 6 additions & 4 deletions algorithms/linfa-bayes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ default-features = false
features = ["std", "derive"]

[dependencies]
ndarray = { version = "0.15" , features = ["approx"]}
ndarray-stats = "0.5"
ndarray = { version = "0.16", features = ["approx"] }
ndarray-stats = "0.6"
thiserror = "1.0"

linfa = { version = "0.7.1", path = "../.." }

[dev-dependencies]
approx = "0.4"
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = ["winequality"] }
approx = "0.5"
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
"winequality",
] }
16 changes: 8 additions & 8 deletions algorithms/linfa-clustering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ default-features = false
features = ["std", "derive"]

[dependencies]
ndarray = { version = "0.15", features = ["rayon", "approx"] }
linfa-linalg = { version = "0.1", default-features = false }
ndarray-linalg = { version = "0.16", optional = true }
ndarray-rand = "0.14"
ndarray-stats = "0.5"
ndarray = { version = "0.16", features = ["rayon", "approx"] }
linfa-linalg = { version = "0.2", default-features = false }
ndarray-linalg = { version = "0.17", optional = true }
ndarray-rand = "0.15"
ndarray-stats = "0.6"
num-traits = "0.2"
rand_xoshiro = "0.6"
space = "0.12"
Expand All @@ -50,14 +50,14 @@ linfa-nn = { version = "0.7.1", path = "../linfa-nn" }
noisy_float = "0.2.0"

[dev-dependencies]
ndarray-npy = { version = "0.8", default-features = false }
ndarray-npy = { version = "0.9", default-features = false }
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
"generate",
] }
criterion = "0.4.0"
serde_json = "1"
approx = "0.4"
lax = "0.15.0"
approx = "0.5"
lax = "0.17.0"
linfa = { version = "0.7.1", path = "../..", features = ["benchmarks"] }

[[bench]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<F: Float> GaussianMixtureModel<F> {
let n_clusters = matrix_chol.shape()[0];
let log_diags = &matrix_chol
.to_owned()
.into_shape((n_clusters, n_features * n_features))
.into_shape_with_order((n_clusters, n_features * n_features))
.unwrap()
.slice(s![.., ..; n_features+1])
.to_owned()
Expand Down
10 changes: 5 additions & 5 deletions algorithms/linfa-elasticnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ default-features = false
features = ["std", "derive"]

[dependencies]
ndarray = { version = "0.15", features = ["approx"] }
linfa-linalg = { version = "0.1", default-features = false }
ndarray-linalg = { version = "0.16", optional = true }
ndarray = { version = "0.16", features = ["approx"] }
linfa-linalg = { version = "0.2", default-features = false }
ndarray-linalg = { version = "0.17", optional = true }

num-traits = "0.2"
approx = "0.4"
approx = "0.5"
thiserror = "1.0"

linfa = { version = "0.7.1", path = "../.." }
Expand All @@ -44,5 +44,5 @@ linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
"diabetes",
"linnerud",
] }
ndarray-rand = "0.14"
ndarray-rand = "0.15"
rand_xoshiro = "0.6"
4 changes: 2 additions & 2 deletions algorithms/linfa-ftrl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ version = "1.0"
features = ["derive"]

[dependencies]
ndarray = { version = "0.15.4", features = ["serde"] }
ndarray = { version = "0.16", features = ["serde"] }
ndarray-rand = "0.14.0"
argmin = { version = "0.9.0", default-features = false }
argmin-math = { version = "0.3", features = ["ndarray_v0_15-nolinalg"] }
Expand All @@ -36,7 +36,7 @@ linfa = { version = "0.7.1", path = "../.." }

[dev-dependencies]
criterion = "0.4.0"
approx = "0.4"
approx = "0.5"
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
"winequality",
] }
Expand Down
16 changes: 12 additions & 4 deletions algorithms/linfa-hierarchical/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-ml/linfa"
readme = "README.md"

keywords = ["hierachical", "agglomerative", "clustering", "machine-learning", "linfa"]
keywords = [
"hierachical",
"agglomerative",
"clustering",
"machine-learning",
"linfa",
]
categories = ["algorithms", "mathematics", "science"]

[dependencies]
ndarray = { version = "0.15" }
ndarray = { version = "0.16" }
kodama = "0.2"
thiserror = "1.0.25"

Expand All @@ -23,5 +29,7 @@ linfa-kernel = { version = "0.7.1", path = "../linfa-kernel" }

[dev-dependencies]
rand = "0.8"
ndarray-rand = "0.14"
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = ["iris"] }
ndarray-rand = "0.15"
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
"iris",
] }
12 changes: 6 additions & 6 deletions algorithms/linfa-ica/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ default-features = false
features = ["std", "derive"]

[dependencies]
ndarray = { version = "0.15" }
linfa-linalg = { version = "0.1", default-features = false }
ndarray-linalg = { version = "0.16", optional = true }
ndarray-rand = "0.14"
ndarray-stats = "0.5"
ndarray = { version = "0.16" }
linfa-linalg = { version = "0.2", default-features = false }
ndarray-linalg = { version = "0.17", optional = true }
ndarray-rand = "0.15"
ndarray-stats = "0.6"
num-traits = "0.2"
rand_xoshiro = "0.6"
thiserror = "1.0"

linfa = { version = "0.7.1", path = "../.." }

[dev-dependencies]
ndarray-npy = { version = "0.8", default-features = false }
ndarray-npy = { version = "0.9", default-features = false }
paste = "1.0"
criterion = "0.4.0"
linfa = { version = "0.7.1", path = "../..", features = ["benchmarks"] }
Expand Down
4 changes: 2 additions & 2 deletions algorithms/linfa-kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ default-features = false
features = ["std", "derive"]

[dependencies]
ndarray = "0.15"
ndarray = "0.16"
num-traits = "0.2"
sprs = { version = "=0.11.1", default-features = false }
sprs = { version = "0.11", default-features = false }

linfa = { version = "0.7.1", path = "../.." }
linfa-nn = { version = "0.7.1", path = "../linfa-nn" }
8 changes: 4 additions & 4 deletions algorithms/linfa-linear/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ default-features = false
features = ["std", "derive"]

[dependencies]
ndarray = { version = "0.15", features = ["approx"] }
linfa-linalg = { version = "0.1", default-features = false }
ndarray-linalg = { version = "0.16", optional = true }
ndarray = { version = "0.16", features = ["approx"] }
linfa-linalg = { version = "0.2", default-features = false }
ndarray-linalg = { version = "0.17", optional = true }
num-traits = "0.2"
argmin = { version = "0.9.0", default-features = false }
argmin-math = { version = "0.3", features = ["ndarray_v0_15-nolinalg"] }
Expand All @@ -43,7 +43,7 @@ linfa = { version = "0.7.1", path = "../.." }
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
"diabetes",
] }
approx = "0.4"
approx = "0.5"
criterion = "0.4.0"
statrs = "0.16.0"
linfa = { version = "0.7.1", path = "../..", features = ["benchmarks"] }
Expand Down
4 changes: 2 additions & 2 deletions algorithms/linfa-logistic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ optional = true
version = "1.0"

[dependencies]
ndarray = { version = "0.15", features = ["approx"] }
ndarray = { version = "0.16", features = ["approx"] }
ndarray-stats = "0.5.0"
num-traits = "0.2"
argmin = { version = "0.9.0", default-features = false }
Expand All @@ -34,7 +34,7 @@ thiserror = "1.0"
linfa = { version = "0.7.1", path = "../.." }

[dev-dependencies]
approx = "0.4"
approx = "0.5"
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
"winequality",
] }
Expand Down
13 changes: 8 additions & 5 deletions algorithms/linfa-logistic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,9 @@ fn logistic_loss<F: Float, A: Data<Elem = F>>(
) -> F {
let n_features = x.shape()[1];
let (params, intercept) = convert_params(n_features, w);
let yz = x.dot(&params.into_shape((params.len(), 1)).unwrap()) + intercept;
let yz = x.dot(&params.into_shape_with_order((params.len(), 1)).unwrap()) + intercept;
let len = yz.len();
let mut yz = yz.into_shape(len).unwrap() * y;
let mut yz = yz.into_shape_with_order(len).unwrap() * y;
yz.mapv_inplace(log_logistic);
-yz.sum() + F::cast(0.5) * alpha * params.dot(&params)
}
Expand All @@ -492,9 +492,9 @@ fn logistic_grad<F: Float, A: Data<Elem = F>>(
) -> Array1<F> {
let n_features = x.shape()[1];
let (params, intercept) = convert_params(n_features, w);
let yz = x.dot(&params.into_shape((params.len(), 1)).unwrap()) + intercept;
let yz = x.dot(&params.into_shape_with_order((params.len(), 1)).unwrap()) + intercept;
let len = yz.len();
let mut yz = yz.into_shape(len).unwrap() * y;
let mut yz = yz.into_shape_with_order(len).unwrap() * y;
yz.mapv_inplace(logistic);
yz -= F::one();
yz *= y;
Expand Down Expand Up @@ -523,7 +523,10 @@ fn multi_logistic_prob_params<'a, F: Float, A: Data<Elem = F>>(
let h = x.dot(&params) + intercept;
// This computes `H - log(sum(exp(H)))`, which is equal to
// `log(softmax(H)) = log(exp(H) / sum(exp(H)))`
let log_prob = &h - log_sum_exp(&h, Axis(1)).into_shape((h.nrows(), 1)).unwrap();
let log_prob = &h
- log_sum_exp(&h, Axis(1))
.into_shape_with_order((h.nrows(), 1))
.unwrap();
(log_prob, params)
}

Expand Down
8 changes: 4 additions & 4 deletions algorithms/linfa-nn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ default-features = false
features = ["std", "derive"]

[dependencies]
ndarray = { version = "0.15", features = ["approx"]}
ndarray-stats = "0.5"
ndarray = { version = "0.16", features = ["approx"] }
ndarray-stats = "0.6"
num-traits = "0.2.0"
noisy_float = "0.2.0"
order-stat = "0.1.3"
Expand All @@ -36,10 +36,10 @@ kdtree = "0.6.0"
linfa = { version = "0.7.1", path = "../.." }

[dev-dependencies]
approx = "0.4"
approx = "0.5"
criterion = "0.4.0"
rand_xoshiro = "0.6"
ndarray-rand = "0.14"
ndarray-rand = "0.15"
linfa = { version = "0.7.1", path = "../..", features = ["benchmarks"] }

[[bench]]
Expand Down
12 changes: 6 additions & 6 deletions algorithms/linfa-pls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ default-features = false
features = ["std", "derive"]

[dependencies]
ndarray = { version = "0.15" }
linfa-linalg = { version = "0.1", default-features = false }
ndarray-linalg = { version = "0.16", optional = true }
ndarray-stats = "0.5"
ndarray-rand = "0.14"
ndarray = { version = "0.16" }
linfa-linalg = { version = "0.2", default-features = false }
ndarray-linalg = { version = "0.17", optional = true }
ndarray-stats = "0.6"
ndarray-rand = "0.15"
num-traits = "0.2"
paste = "1.0"
thiserror = "1.0"
Expand All @@ -40,7 +40,7 @@ linfa = { version = "0.7.1", path = "../..", features = ["benchmarks"] }
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
"linnerud",
] }
approx = "0.4"
approx = "0.5"
rand_xoshiro = "0.6"
criterion = "0.4.0"
statrs = "0.16.0"
Expand Down
14 changes: 7 additions & 7 deletions algorithms/linfa-preprocessing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ serde = ["serde_crate", "ndarray/serde", "serde_regex"]

[dependencies]
linfa = { version = "0.7.1", path = "../.." }
ndarray = { version = "0.15", features = ["approx"] }
ndarray-linalg = { version = "0.16", optional = true }
linfa-linalg = { version = "0.1", default-features = false }
ndarray-stats = "0.5"
ndarray = { version = "0.16", features = ["approx"] }
ndarray-linalg = { version = "0.17", optional = true }
linfa-linalg = { version = "0.2", default-features = false }
ndarray-stats = "0.6"
thiserror = "1.0"
approx = { version = "0.4" }
ndarray-rand = { version = "0.14" }
approx = "0.5"
ndarray-rand = "0.15"
unicode-normalization = "0.1.8"
regex = "1.4.5"
encoding = "0.2"
sprs = { version = "=0.11.1", default-features = false }
sprs = { version = "0.11", default-features = false }

serde_regex = { version = "1.1", optional = true }

Expand Down
14 changes: 7 additions & 7 deletions algorithms/linfa-reduction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ default-features = false
features = ["std", "derive"]

[dependencies]
ndarray = { version = "0.15", features = ["approx"] }
linfa-linalg = { version = "0.1" }
ndarray-linalg = { version = "0.16", optional = true }
ndarray-rand = "0.14"
ndarray = { version = "0.16", features = ["approx"] }
linfa-linalg = { version = "0.2" }
ndarray-linalg = { version = "0.17", optional = true }
ndarray-rand = "0.15"
num-traits = "0.2"
thiserror = "1.0"
rand = { version = "0.8", features = ["small_rng"] }

linfa = { version = "0.7.1", path = "../.." }
linfa-kernel = { version = "0.7.1", path = "../linfa-kernel" }
sprs = "=0.11.1"
sprs = { version = "0.11" }
rand_xoshiro = "0.6.0"

[dev-dependencies]
ndarray-npy = { version = "0.8", default-features = false }
ndarray-npy = { version = "0.9", default-features = false }
linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
"iris",
"generate",
] }
approx = { version = "0.4" }
approx = "0.5"
mnist = { version = "0.6.0", features = ["download"] }
linfa-trees = { version = "0.7.1", path = "../linfa-trees" }
6 changes: 3 additions & 3 deletions algorithms/linfa-svm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ default-features = false
features = ["std", "derive"]

[dependencies]
ndarray = { version = "0.15" }
ndarray-rand = "0.14"
ndarray = { version = "0.16" }
ndarray-rand = "0.15"
num-traits = "0.2"
thiserror = "1.0"

Expand All @@ -38,4 +38,4 @@ linfa-datasets = { version = "0.7.1", path = "../../datasets", features = [
"diabetes",
] }
rand_xoshiro = "0.6"
approx = "0.4"
approx = "0.5"
Loading
Loading