Skip to content

Commit 9de9c26

Browse files
committed
Added data exception checker
1 parent 7904694 commit 9de9c26

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

MachineLearning/TensorFlow/lltm_mlp.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import matplotlib.pyplot as plt
1010

1111
# definitions
12-
FILE_NAME = "newdata0725_variable_interval.csv"
12+
FILE_NAME = "newdata.csv"
1313
# FILE_NAME = "test.csv"
1414
TIME_INTERVAL = 10 # records per second
1515

@@ -21,7 +21,7 @@
2121

2222
LEARNING_RATE = 0.003
2323
STANDARD_DEVIATION = 0.1
24-
TRAINING_EPOCHS = 1000
24+
TRAINING_EPOCHS = 10
2525
BATCH_SIZE = 50 # 100
2626
DISPLAY_STEP = 20
2727
RANDOM_STATE = 100
@@ -47,6 +47,12 @@ def find_second_beg(data_set, start_second):
4747
return start_idx
4848

4949

50+
def outputSpecialData(arr, val):
51+
for i in range(len(arr)):
52+
if arr[i] > val or arr[i] < -val:
53+
print("" + i + arr[i])
54+
55+
5056
# fetch data from csv file
5157
# data format:
5258
# [0]: time
@@ -62,7 +68,7 @@ def find_second_beg(data_set, start_second):
6268
raw_linear_heave = np.array(raw_data[:, 2])
6369
raw_real_heave = np.array(raw_data[:, 3])
6470
raw_nonlinear_heave = np.subtract(raw_real_heave, raw_linear_heave)
65-
print(raw_nonlinear_heave[0])
71+
# outputSpecialData(raw_nonlinear_heave, 1)
6672

6773
print(raw_data[find_second_beg(raw_data, 101)])
6874
print(raw_data[find_second_beg(raw_data, 120)])
@@ -76,6 +82,7 @@ def find_second_beg(data_set, start_second):
7682
training_target[i] = [raw_nonlinear_heave[training_data_idx_start + i]]
7783
training_input = np.array(training_input)
7884
training_target = np.array(training_target)
85+
# outputSpecialData(training_target, 1)
7986
print(training_input.shape)
8087
print(training_target.shape)
8188

@@ -87,9 +94,11 @@ def find_second_beg(data_set, start_second):
8794
testing_target[i] = [raw_nonlinear_heave[testing_data_idx_start + i]]
8895
testing_input = np.array(testing_input)
8996
testing_target = np.array(testing_target)
97+
# outputSpecialData(testing_target, 1)
9098
print(testing_input.shape)
9199
print(testing_target.shape)
92100

101+
93102
# NRMSE
94103
def nrmse(real, predict):
95104
up = tf.sqrt(tf.reduce_sum(tf.square(real - predict)))
@@ -218,6 +227,7 @@ def mlp(_x, _weights, _biases):
218227
# Testing
219228
test_acc = sess.run(pred, feed_dict={X: testing_input, y: testing_target, dropout_keep_prob: 1.})
220229
# print("Test accuracy: %.6f" % test_acc)
230+
outputSpecialData(testing_target, 1)
221231
print(repr(np.column_stack((test_acc, testing_target))))
222232
# for i in np.column_stack((test_acc, testing_target)):
223233
# print(repr(i))

0 commit comments

Comments
 (0)