Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Image classification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cart Milan
Image classification
Commits
319c8de1
Commit
319c8de1
authored
1 year ago
by
Cart Milan
Browse files
Options
Downloads
Patches
Plain Diff
Part 1 : Prepare the CIFAR dataset
parent
49087cb0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
__pycache__/read_cifar.cpython-311.pyc
+0
-0
0 additions, 0 deletions
__pycache__/read_cifar.cpython-311.pyc
read_cifar.py
+38
-1
38 additions, 1 deletion
read_cifar.py
test.py
+2
-0
2 additions, 0 deletions
test.py
with
40 additions
and
1 deletion
__pycache__/read_cifar.cpython-311.pyc
0 → 100644
+
0
−
0
View file @
319c8de1
File added
This diff is collapsed.
Click to expand it.
read_cifar.py
+
38
−
1
View file @
319c8de1
import
numpy
as
np
import
pickle
from
sklearn.model_selection
import
train_test_split
import
pandas
as
pd
import
pickle
...
...
@@ -12,4 +16,37 @@ def read_cifar_batch(batch_path):
return
data
,
labels
print
(
read_cifar_batch
(
'
Data/cifar-10-batches-py/data_batch_2
'
))
\ No newline at end of file
def
read_cifar
(
path
):
data
=
[]
labels
=
[]
#Add the 5 batches
for
i
in
range
(
1
,
6
):
data_temp
,
labels_temp
=
read_cifar_batch
(
f
'
{
path
}
/data_batch_
{
i
}
'
)
data
.
append
(
data_temp
)
labels
.
append
(
labels_temp
)
#Add the test batches
data_temp
,
labels_temp
=
read_cifar_batch
(
f
'
{
path
}
/test_batch
'
)
data
.
append
(
data_temp
)
labels
.
append
(
labels_temp
)
#Concatenate all the batches to create a big one
data
=
np
.
concatenate
(
data
,
axis
=
0
)
labels
=
np
.
concatenate
(
labels
,
axis
=
0
)
return
(
data
,
labels
)
def
split_dataset
(
data
,
labels
,
split
):
X_train
,
X_test
,
y_train
,
y_test
=
train_test_split
(
data
,
labels
,
test_size
=
(
1
-
split
),
random_state
=
0
)
return
(
X_train
,
X_test
,
y_train
,
y_test
)
if
__name__
==
'
__main__
'
:
data
,
labels
=
read_cifar_batch
(
'
Data/cifar-10-batches-py/data_batch_1
'
)
data
,
labels
=
read_cifar
(
'
/Users/milancart/Documents/GitHub/image-classification/Data/cifar-10-batches-py
'
)
X_train
,
X_test
,
y_train
,
y_test
=
split_dataset
(
data
,
labels
,
0.8
)
print
(
X_train
,
X_test
,
y_train
,
y_test
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test.py
0 → 100644
+
2
−
0
View file @
319c8de1
import
read_cifar
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment