Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-220
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-220
2022-220
Commits
da2af853
Commit
da2af853
authored
Nov 13, 2022
by
Pathirana K.P.G.I
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
08b46b72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
training.py
training.py
+54
-0
No files found.
training.py
0 → 100644
View file @
da2af853
import
numpy
as
np
data
=
np
.
load
(
'Processed_Data/data.npy'
)
target
=
np
.
load
(
'Processed_Data/target.npy'
)
from
keras.models
import
Sequential
from
keras.layers
import
Dense
,
Activation
,
Flatten
,
Dropout
from
keras.layers
import
Conv2D
,
MaxPooling2D
model
=
Sequential
()
model
.
add
(
Conv2D
(
256
,
(
3
,
3
),
input_shape
=
data
.
shape
[
1
:]))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Conv2D
(
128
,
(
3
,
3
)))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Flatten
())
model
.
add
(
Dropout
(
0.5
))
model
.
add
(
Dense
(
64
,
activation
=
'relu'
))
model
.
add
(
Dense
(
10
,
activation
=
'softmax'
))
model
.
compile
(
loss
=
'categorical_crossentropy'
,
optimizer
=
'adam'
,
metrics
=
[
'accuracy'
])
from
sklearn.model_selection
import
train_test_split
train_data
,
test_data
,
train_target
,
test_target
=
train_test_split
(
data
,
target
,
test_size
=
0.1
)
history
=
model
.
fit
(
train_data
,
train_target
,
epochs
=
100
,
validation_split
=
0.1
)
from
matplotlib
import
pyplot
as
plt
plt
.
plot
(
history
.
history
[
'loss'
],
'b'
)
plt
.
plot
(
history
.
history
[
'val_loss'
],
'r'
)
from
matplotlib
import
pyplot
as
plt
plt
.
plot
(
history
.
history
[
'accuracy'
],
'b'
)
plt
.
plot
(
history
.
history
[
'val_accuracy'
],
'r'
)
print
(
model
.
evaluate
(
test_data
,
test_target
))
model
.
save_weights
(
'model.h5'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment