summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2016-03-28 20:05:24 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2016-03-28 20:05:24 +0200
commit117b39ffe1a642fa418ac0490717fd1fdfcbdb78 (patch)
treea3bf2945a1ab57b01c9c0eac03ec5352726fbd50
parent13682b432e09b60c936108530f87d6913f9ac3c1 (diff)
downloadboston-neuralnet-117b39ffe1a642fa418ac0490717fd1fdfcbdb78.tar.gz
boston-neuralnet-117b39ffe1a642fa418ac0490717fd1fdfcbdb78.zip
speichere in JSON
-rw-r--r--neuralnet.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/neuralnet.py b/neuralnet.py
index 8eb31cb..6434e8a 100644
--- a/neuralnet.py
+++ b/neuralnet.py
@@ -6,6 +6,7 @@ import tensorflow as tf
import numpy.random
import numpy as np
import os
+import json
# Siehe Kommentar in dem Programm der linearen Regression
SEED = 42
@@ -98,28 +99,28 @@ with tf.device('/cpu:0'):
# Alle Tensorflow-Variablen müssen bis hier spezifiziert sein!
sess.run(tf.initialize_all_variables())
+ jsonLog = dict()
# Training
for count in range(0, int(len(x_train) / BATCH)):
+ jsonLog[count] = dict()
print("batch " + str(count))
for i in range(0, STEPS):
result = sess.run([summaries,
- matWeights, matWeightsHidden, vecBias,
- train_step],
+ vecBias, matWeights, matWeightsHidden,
+ train_step],
feed_dict={
- matInput: x_train[count*BATCH:(count+1)*BATCH],
- vecTarget: y_train[count*BATCH:(count+1)*BATCH]
+ matInput: x_train[count*BATCH:(count+1)*BATCH],
+ vecTarget: y_train[count*BATCH:(count+1)*BATCH]
})
writer.add_summary(result[0], count * STEPS + i)
- logdir = "inspect/" + str(count) + "/" + str(i) + "/"
- if not os.path.exists(logdir):
- os.makedirs(logdir)
- numpy.savetxt(logdir + "/weights.csv",
- result[1], delimiter=",")
- numpy.savetxt(logdir + "/weights-hidden.csv",
- result[2], delimiter=",")
- numpy.savetxt(logdir + "/bias.csv",
- result[1], delimiter=",")
+ if not os.path.exists("inspect"):
+ os.makedirs("inspect")
+ jsonLog[count][i] =\
+ [[result[1].tolist()]] + [a.tolist() for a in result[2:4]]
+ f = open("inspect/log.json", "w+")
+ json.dump(jsonLog, f)
+ f.close()
print("Training beendet")