def predict(X1): X1.resize((samples, neurons), refcheck=False) result = sess.run(l5, feed_dict={x: X1, y: test_y, keep_prob: 1}) return result[:test_y.shape[0]] features = 179 rows = 4600 LR = 0.0001 epochs = 301 Xavier = 0.8 beta = 0.0001 X, Y = read_dataset(features, rows, Type.epilepsy) train_x, test_x, train_y, test_y = train_test_split(X, Y, test_size=0.20, random_state=5) neurons = train_x.shape[1] samples = train_x.shape[0] keep_prob = tf.placeholder("float") x = tf.placeholder(tf.float32, shape=[None, neurons]) y = tf.placeholder(tf.float32, shape=[None, 1]) W0 = tf.Variable(tf.truncated_normal([neurons, samples], seed=1), name="W0", dtype=tf.float32) * Xavier b0 = tf.Variable(tf.zeros([samples, 1]), name="bias0", dtype=tf.float32) W1 = tf.Variable(tf.truncated_normal([samples, neurons], seed=0), name="W1", dtype=tf.float32) * Xavier b1 = tf.Variable(tf.zeros([samples, 1]), name="bias1", dtype=tf.float32) W2 = tf.Variable(tf.truncated_normal([neurons, samples], seed=0), name="W2", dtype=tf.float32) * Xavier b2 = tf.Variable(tf.zeros([samples, 1]), name="bias2", dtype=tf.float32) W3 = tf.Variable(tf.truncated_normal([samples, samples], seed=0), name="W3", dtype=tf.float32) * Xavier b3 = tf.Variable(tf.zeros([samples, 1]), name="bias3", dtype=tf.float32)
from NN3 import NN3 from sklearn.model_selection import train_test_split from nn_utils import read_dataset X, Y = read_dataset(180, 500) dataset = train_test_split( X, Y, test_size=0.3, random_state=1) epochs = 6000 nn3 = NN3(dataset, epochs, print_step=600)
import tensorflow as tf import numpy as np from sklearn.model_selection import train_test_split from nn_utils import read_dataset def predict(X1): X1.resize((samples, neurons), refcheck=False) result = sess.run(l4, feed_dict={x: X1, y: test_y, keep_prob: 1}) return result[:test_y.shape[0]] X, Y = read_dataset(180, 1000) train_x, test_x, train_y, test_y = train_test_split(X, Y, test_size=0.20, random_state=5) LR = 0.0001 epochs = 4000 neurons = train_x.shape[1] samples = train_x.shape[0] keep_prob = tf.placeholder("float") Xavier = 0.3 x = tf.placeholder(tf.float32, shape=[None, neurons]) y = tf.placeholder(tf.float32, shape=[None, 1]) W0 = tf.Variable(tf.truncated_normal([neurons, samples], seed=1), name="W0", dtype=tf.float32) * Xavier b0 = tf.Variable(tf.zeros([samples, 1]), name="bias0", dtype=tf.float32)
import numpy as np from nn_utils import read_dataset size = 1000 def sigmoid(x, deriv=False): if (deriv == True): return x * (1 - x) return 1 / (1 + np.exp(-x)) X, y = read_dataset(180, 1000) np.random.seed(5) # synapses w0 = 2 * np.random.random((X.size / X.__len__(), X.__len__())) - 1 w1 = 2 * np.random.random((X.__len__(), X.__len__())) - 1 w2 = 2 * np.random.random((X.__len__(), 1)) - 1 # training step for j in xrange(60000): # Calculate forward through the network. l0 = X l1 = sigmoid(np.dot(l0, w0)) l2 = sigmoid(np.dot(l1, w1)) l3 = sigmoid(np.dot(l2, w2)) # Error back propagation of errors using the chain rule. l3_error = y - l3
def predict(X1): X1.resize((samples, neurons), refcheck=False) result = sess.run(l5, feed_dict={x: X1, y: test_y, keep_prob: 1}) return result[:test_y.shape[0]] features = 179 rows = 4600 LR = 0.0001 epochs = 6000 Xavier = 0.85 beta = 0.0001 X, Y = read_dataset(features, rows, Type.tumor) train_x, test_x, train_y, test_y = train_test_split(X, Y, test_size=0.20, random_state=5) neurons = train_x.shape[1] samples = train_x.shape[0] s = 2400 keep_prob = tf.placeholder("float") x = tf.placeholder(tf.float32, shape=[None, neurons]) y = tf.placeholder(tf.float32, shape=[None, 1]) W0 = tf.Variable(tf.truncated_normal([neurons, samples], seed=1), name="W0", dtype=tf.float32) * Xavier b0 = tf.Variable(tf.zeros([samples, 1]), name="bias0", dtype=tf.float32)