浏览代码

Write the high level structure of source code

DricomDragon 5 年之前
父节点
当前提交
9bc1aa4926
共有 6 个文件被更改,包括 88 次插入0 次删除
  1. 12 0
      python/lab/benchmark.py
  2. 21 0
      python/lab/generator.py
  3. 0 0
      python/lab/io_mnist.py
  4. 7 0
      python/lab/neural.py
  5. 20 0
      python/lab/trainer.py
  6. 28 0
      python/start_session.py

+ 12 - 0
python/lab/benchmark.py

@@ -0,0 +1,12 @@
+# Measure performance
+
+from lab import neural
+
+def computePrecision(network):
+	"""
+	Test performance of provided network.
+
+	return : ratio of good answers in [0.0 ; 1.0]
+	"""
+	# TODO
+	return 0.0

+ 21 - 0
python/lab/generator.py

@@ -0,0 +1,21 @@
+# Generate neural network
+
+from lab import neural
+
+# Random generators
+def flat():
+	return 0
+
+def uniform():
+	# TODO
+	return 0
+
+def gaussUnitDev():
+	# TODO
+	return 0
+
+# Network weight initialization
+def generate(activation, weightGenerator = flat):
+	# TODO
+	return neural.Network()
+

python/src/io_mnist.py → python/lab/io_mnist.py


+ 7 - 0
python/lab/neural.py

@@ -0,0 +1,7 @@
+# Hold the network attributes
+
+class Network():
+	def __init__(self):
+		# TODO
+		print("Created")
+

+ 20 - 0
python/lab/trainer.py

@@ -0,0 +1,20 @@
+# Improve performance of neural network
+
+from lab import neural
+from copy import copy
+
+def train(inputNetwork, learnRate, epochs):
+	"""
+	Create an improved network
+
+	inputNetwork : the network to be trained
+	epochs : the number of iterations
+
+	return : a trained copy with improved performance
+	"""
+	outputNetwork = copy(inputNetwork)
+
+	# TODO Training
+
+	return outputNetwork
+

+ 28 - 0
python/start_session.py

@@ -0,0 +1,28 @@
+#!/usr/bin/python3
+
+# File designed to be launched by user
+print("Start session")
+
+# Import python libraries
+from scipy.special import expit
+
+# Import local code to call
+from lab import generator, trainer, benchmark
+
+# Parameters
+learnRate = 0.05
+activation = expit
+epochs = 10
+
+# Session
+newNetwork = generator.generate(activation, generator.gaussUnitDev)
+
+trainedNetwork = trainer.train(newNetwork, learnRate, epochs)
+
+precisionBefore = benchmark.computePrecision(newNetwork)
+precisionAfter = benchmark.computePrecision(trainedNetwork)
+
+# Display results
+print("Precision before training : ", precisionBefore)
+print("Precision after training : ", precisionAfter)
+