Skip to content

Commit

Permalink
capacity for dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
cospectrum committed May 10, 2024
1 parent 2eaa686 commit 74b7865
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dataset/impl_dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,13 @@ where
)> {
let targets = self.as_targets();
let fold_size = targets.len() / k;
let mut res = Vec::new();

// Generates all k folds of records and targets
let mut records_chunks: Vec<_> =
self.records.axis_chunks_iter(Axis(0), fold_size).collect();
let mut targets_chunks: Vec<_> = targets.axis_chunks_iter(Axis(0), fold_size).collect();

let mut res = Vec::with_capacity(k);
// For each iteration, take the first chunk for both records and targets as the validation set and
// concatenate all the other chunks to create the training set. In the end swap the first chunk with the
// one in the next index so that it is ready for the next iteration
Expand Down Expand Up @@ -742,7 +742,7 @@ where
let targets = self.ntargets();
let tshape = self.targets.raw_dim();

let mut objs: Vec<O> = Vec::new();
let mut objs: Vec<O> = Vec::with_capacity(k);

{
let records_sl = self.records.as_slice_mut().unwrap();
Expand Down

0 comments on commit 74b7865

Please sign in to comment.