Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
code
pfabric
Commits
9e9a0f42
Commit
9e9a0f42
authored
Feb 08, 2018
by
Constantin Pohl
Browse files
+7% accuracy (Philipps idea)
parent
edcbb3d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/DEBS2018/training/train_tf.py
View file @
9e9a0f42
...
...
@@ -40,12 +40,13 @@ def build_model_columns():
#numeric column because of float value in certain range
#COURSE is the key, necessary to map attribute to feature column
course
=
tf
.
feature_column
.
numeric_column
(
'COURSE'
)
shiptype
=
tf
.
feature_column
.
numeric_column
(
'SHIPTYPE'
)
#see above
lon
=
tf
.
feature_column
.
numeric_column
(
'LON'
)
lat
=
tf
.
feature_column
.
numeric_column
(
'LAT'
)
#combine to single variable
base_columns
=
[
course
,
lon
,
lat
]
base_columns
=
[
lon
,
lat
,
course
,
shiptype
]
return
base_columns
#construct estimator for the model (with directory specification)
...
...
@@ -79,6 +80,10 @@ def input_fn(data_file, num_epochs, batch_size):
#reading raw file
dataset
=
tf
.
data
.
TextLineDataset
(
data_file
)
#shuffle for each epoch run
#HINT: does not improve accuracy; since there are timestamps shuffling maybe not useful
#dataset = dataset.shuffle(buffer_size=32000)
#map and parse input strings into features
dataset
=
dataset
.
map
(
parse_csv
,
num_parallel_calls
=
5
)
...
...
@@ -94,8 +99,12 @@ def input_fn(data_file, num_epochs, batch_size):
#main
def
main
(
unused_argv
):
#parametrization
#for a good explanation look at https://towardsdatascience.com/epoch-vs-iterations-vs-batch-size-4dfb9c7ce9c9
#num_epochs is the number of full runs through the training data file (5 = run five times)
num_epochs
=
5
#batch_size derives the amount of steps in each epoch (1 means there is one step with all 400.000 input tuples at once)
batch_size
=
10
#directories
model_dir
=
"./model/"
train_data
=
"./train_data/training_data.csv"
test_data
=
"./train_data/testing_data.csv"
...
...
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