From f5d461faf13df6896fe2c71c5162c592ceead1ce Mon Sep 17 00:00:00 2001 From: Sai Raghava Reddy Ganapaa Date: Tue, 21 May 2019 17:11:35 +0200 Subject: [PATCH] updating input function for knowledge transfer --- spider_control/control.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spider_control/control.py b/spider_control/control.py index 38cd93f..a6a1c1b 100644 --- a/spider_control/control.py +++ b/spider_control/control.py @@ -241,6 +241,7 @@ class Architecture: bias_h = tf.placeholder(tf.float32, shape=(neurons/3, layers)) bias_h_c = tf.placeholder(tf.float32, shape=(neurons/3, layers)) def weight_initialize (self): + rand_array_i = np.random.rand(24, 3) with tf.Session() as sess_i: sess_i.run(weight_i, feed_dict={weight_i: rand_array_i}) @@ -257,6 +258,34 @@ class Architecture: def get_neuron_value(self, a, b): with tf.Session() as sess_n: sess_n.run(a, feed_dict={a: b}) + #class that describes multi class logistic regression for knowledge transfer +class MultiClassLogistic: + + def __init__(self, neurons, neuron_values, layers): + self.neurons = neurons + self.layers = layers + self.neuron_values = neuron_values #assigning input neuron values + weights1 = tf.random_normal((neurons, 1), dtype=float32, seed=1606)#weights of input layer + weights2 = tf.random_normal((neurons/4, 1), dtype=float32, seed=1003)#weights for hidden layer, number of neurons in hidden layer is identified by the quadrant concept + weights3 = tf.random_normal((neurons, 1), dtype=float32, seed=0207)#weights for output layer + sess = tf.Session() + weight_in, weight_hid, weight_out = sess.run(weights1, weights2, weights3) + + #defining input function that can accept the output from previous layer and can calculate the input for present layer + + def input_function(self, a, b): + 'where a=output value of neurons from previous layer, b = weights of neurons from the present layer' + rand1 = tf.random_uniform(shape, minval=0, maxval=1, dtype=tf.float32, seed=1009)#creating a random number + rand2 =tf.random_uniform(shape, minval=0, maxval=1, dtype=tf.float32, seed=2301) + m1 = np.insert(a, rand1, a[0]) + m2 = np.insert(b, rand2, b[0]) + multiplication = tf.matmul(m1, m2) + sess = tf.Session() + n_input = sess.run(multiplication) + return n_input + + + #function to normalize the input data def normalization(a): -- GitLab