-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a pickle dataset, that contains predetermined batches
- Loading branch information
Showing
8 changed files
with
206 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!-- | ||
Copyright (c) 2024 Hannah contributors. | ||
This file is part of hannah. | ||
See https://github.com/ekut-es/hannah for further info. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
# Test Pickle dataset | ||
|
||
A simple test implementation for pickled datasets. | ||
|
||
The pickled datasets are expected to contain a tuple of numpy arrays. | ||
|
||
The first array contains the (preprocessed) input data, the second array contains the target class ids as int32 values. | ||
|
||
## Creating Test Data | ||
|
||
The following creates test, val and train datasets with 400, 400 and 4000 samples respectively. | ||
The data is randomly initialized, and the classes are also randomly attached to a number of 2. | ||
|
||
python create_sample.py --size 400 --dim='(20,17)' --classes=2 test.pkl | ||
python create_sample.py --size 400 --dim='(20,17)' --classes=2 val.pkl | ||
python create_sample.py --size 4000 --dim='(20,17)' --classes=2 train.pkl | ||
|
||
## Training | ||
|
||
This then runs a training on tc-res8 | ||
|
||
hannah-train |
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,28 @@ | ||
## | ||
## Copyright (c) 2022 University of Tübingen. | ||
## | ||
## This file is part of hannah. | ||
## See https://atreus.informatik.uni-tuebingen.de/ties/ai/hannah/hannah for further info. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
|
||
|
||
defaults: | ||
- base_config # Base configuration uses a single neural network training and kws dataset | ||
- override dataset: test_pickle_set # Override the dataset to use the test_pickle_set dataset | ||
- override features: raw # Override the features to not use any preprocessing | ||
- _self_ # This is a special value that specifies that values defined in this file take precedence over values from the other files | ||
|
||
trainer: # Trainer arguments set hyperparameters for all trainings | ||
max_epochs: 30 |
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,50 @@ | ||
# | ||
# Copyright (c) 2024 Hannah contributors. | ||
# | ||
# This file is part of hannah. | ||
# See https://github.com/ekut-es/hannah for further info. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
import argparse | ||
import os | ||
import pickle | ||
|
||
import numpy | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description="This script converts a pickle file to a numpy file." | ||
) | ||
parser.add_argument("pickle_file", help="The pickle file to create.") | ||
parser.add_argument("--size", help="The number of samples in the dataset.") | ||
parser.add_argument( | ||
"--dim", | ||
help='The dimension of the samples, in the form of a tuple e.g. "(3, 32, 32)"', | ||
) | ||
parser.add_argument("--classes", help="The number of classes in the dataset.") | ||
|
||
args = parser.parse_args() | ||
|
||
size = int(args.size) | ||
dim = tuple(map(int, args.dim.strip("()").split(","))) | ||
classes = int(args.classes) | ||
|
||
with open(args.pickle_file, "wb") as f: | ||
pickle.dump( | ||
( | ||
numpy.random.rand(size, *dim).astype(numpy.float32), | ||
numpy.random.randint(0, classes, size), | ||
), | ||
f, | ||
) |
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,11 @@ | ||
cls: hannah.datasets.pickle_set.PickleDataset | ||
train: | ||
- ${hydra:runtime.cwd}/train.pkl | ||
|
||
val: | ||
- ${hydra:runtime.cwd}/val.pkl | ||
|
||
test: | ||
- ${hydra:runtime.cwd}/test.pkl | ||
|
||
samplingrate: 16000 |
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