Skip to content

Commit 080339e

Browse files
Merge pull request #11 from christianversloot/add-warning-log
Add warning log to datasets
2 parents a67b3d8 + bb93cbf commit 080339e

File tree

6 files changed

+100
-1
lines changed

6 files changed

+100
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
__pycache__/
22
dist/
3-
build/
3+
build/
4+
test.py

extra_keras_datasets/emnist.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818
from zipfile import ZipFile
1919
from scipy import io as sio
2020
import os
21+
import logging
22+
23+
24+
def warn_citation():
25+
"""Warns about citation requirements
26+
# Returns
27+
Void
28+
"""
29+
logging.warning(("Please cite the following paper when using or"
30+
" referencing this Extra Keras Dataset:"))
31+
logging.warning(
32+
("Cohen, G., Afshar, S., Tapson, J., & van Schaik, A. (2017). EMNIST: "
33+
"an extension of MNIST to handwritten letters. "
34+
"Retrieved from http://arxiv.org/abs/1702.05373")
35+
)
2136

2237

2338
def load_data(path="emnist_matlab.npz", type="balanced"):
@@ -64,5 +79,8 @@ def load_data(path="emnist_matlab.npz", type="balanced"):
6479
(input_test.shape[0], 28, 28), order="F"
6580
)
6681

82+
# Warn about citation
83+
warn_citation()
84+
6785
# Return data
6886
return (input_train, target_train), (input_test, target_test)

extra_keras_datasets/iris.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@
1414
from tensorflow.keras.utils import get_file
1515
import numpy as np
1616
import math
17+
import logging
18+
19+
20+
def warn_citation():
21+
"""Warns about citation requirements
22+
# Returns
23+
Void
24+
"""
25+
logging.warning(("Please cite the following paper when using or"
26+
" referencing this Extra Keras Dataset:"))
27+
logging.warning(
28+
("Fisher,R.A. \"The use of multiple measurements in taxonomic "
29+
"problems\" Annual Eugenics, 7, Part II, 179-188 (1936); also "
30+
"in \"Contributions to Mathematical Statistics\" (John Wiley"
31+
", NY, 1950).")
32+
)
1733

1834

1935
def load_data(path="iris.npz", test_split=0.2):
@@ -64,6 +80,9 @@ def load_data(path="iris.npz", test_split=0.2):
6480
target_train = [i[4] for i in training_data]
6581
target_test = [i[4] for i in testing_data]
6682

83+
# Warn about citation
84+
warn_citation()
85+
6786
# Return data
6887
return (input_train, target_train), (input_test, target_test)
6988

extra_keras_datasets/kmnist.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@
1414

1515
from tensorflow.keras.utils import get_file
1616
import numpy as np
17+
import logging
18+
19+
20+
def warn_citation():
21+
"""Warns about citation requirements
22+
# Returns
23+
Void
24+
"""
25+
logging.warning(("Please cite the following paper when using or"
26+
" referencing this Extra Keras Dataset:"))
27+
logging.warning(
28+
("Clanuwat, T., Bober-Irizar, M., Kitamoto, A., Lamb, A., "
29+
"Yamamoto, K., & Ha, D. (2018). Deep learning for classical "
30+
"Japanese literature arXiv preprint arXiv:1812.01718. "
31+
"Retrieved from https://arxiv.org/abs/1812.01718")
32+
)
1733

1834

1935
def load_data(path="kmnist.npz", type="kmnist"):
@@ -58,5 +74,8 @@ def load_data(path="kmnist.npz", type="kmnist"):
5874
)
5975
target_test = np.load(path_test_labels)["arr_0"]
6076

77+
# Warn about citation
78+
warn_citation()
79+
6180
# Return data
6281
return (input_train, target_train), (input_test, target_test)

extra_keras_datasets/stl10.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@
1919
from scipy import io as sio
2020
import shutil
2121
import numpy as np
22+
import logging
23+
24+
25+
def warn_citation():
26+
"""Warns about citation requirements
27+
# Returns
28+
Void
29+
"""
30+
logging.warning(("Please cite the following paper when using or"
31+
" referencing this Extra Keras Dataset:"))
32+
logging.warning(
33+
("Coates, A., Ng, A., & Lee, H. (2011, June). An analysis of single-"
34+
"layer networks in unsupervised feature learning. In Proceedings of"
35+
" the fourteenth international conference on artificial "
36+
"intelligence and statistics (pp. 215-223).Retrieved from "
37+
"http://cs.stanford.edu/~acoates/papers/coatesleeng_aistats_2011.pdf")
38+
)
2239

2340

2441
def load_data(path="stl10_matlab.tar.gz"):
@@ -59,5 +76,8 @@ def load_data(path="stl10_matlab.tar.gz"):
5976
input_test = np.transpose(input_test, (0, 3, 2, 1))
6077
target_test = test["y"].flatten()
6178

79+
# Warn about citation
80+
warn_citation()
81+
6282
# Return data
6383
return (input_train, target_train), (input_test, target_test)

extra_keras_datasets/svhn.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@
1616
from tensorflow.keras.utils import get_file
1717
import numpy as np
1818
from scipy import io as sio
19+
import logging
20+
21+
22+
def warn_citation():
23+
"""Warns about citation requirements
24+
# Returns
25+
Void
26+
"""
27+
logging.warning(("Please cite the following paper when using or"
28+
" referencing this Extra Keras Dataset:"))
29+
logging.warning(
30+
("Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, "
31+
"Andrew Y. Ng Reading Digits in Natural Images with Unsupervised "
32+
"Feature Learning NIPS Workshop on Deep Learning and Unsupervised "
33+
"Feature Learning 2011. Retrieved from "
34+
"http://ufldl.stanford.edu/housenumbers/nips2011_housenumbers.pdf")
35+
)
36+
logging.warning(("Noncommercial use is allowed only: see the "
37+
"SVHN website for more information."))
1938

2039

2140
def load_data(path="svhn_matlab.npz", type="normal"):
@@ -66,5 +85,8 @@ def load_data(path="svhn_matlab.npz", type="normal"):
6685
input_train = np.concatenate((input_extra, input_train))
6786
target_train = np.concatenate((target_extra, target_train))
6887

88+
# Warn about citation
89+
warn_citation()
90+
6991
# Return data
7092
return (input_train, target_train), (input_test, target_test)

0 commit comments

Comments
 (0)