Skip to content

Instantly share code, notes, and snippets.

import numpy as np
x = np.array([1, 2, 3, 4, 5])
y = np.array([1, 4, 9, 16, 25])
learningRate = 0.0001
iterations = 200000
def gradient(m, b):
m_gradient = 0
b_gradient = 0
import numpy as np
inputLayerSize, hiddenLayerSize, outputLayerSize = 2, 3, 1
L = 0.1
X = np.array([[0,0], [0,1], [1,0], [1,1]])
Y = np.array([[0], [1], [1], [0]])
iterations = 50000
#sigmoid function
def f(x): return 1/(1 + np.exp(-x))
import numpy as np
inputLayerSize, hiddenLayerSize, outputLayerSize = 3, 3, 1
L = 0.25
X = np.array([[0, 0, 1], [0, 1, 1], [1, 0, 1], [0, 1, 0], [1, 0, 0], [0, 0, 0], [1, 1, 0]])
Y = np.array([[0], [0], [0], [0], [0], [0], [1]])
iterations = 50000
#sigmoid function
def f(x): return 1/(1 + np.exp(-x))
import csv
import math
import operator
def euclideanDistance(p1, p2, length):
distance = 0
for x in range(length):
distance += pow(p1[x] - p2[x], 2)
return math.sqrt(distance)
import numpy as np
import math
import operator
trainingSet = np.array([
[5.1, 3.5, 1.4, 0.2],
[4.9, 3.0, 1.4, 0.2],
[4.7, 3.2, 1.3, 0.2],
[7.0, 3.2, 4.7, 1.4],
[6.4, 3.2, 4.5, 1.5],
import tensorflow as tf
import numpy as np
tf.set_random_seed(100)
stddev = 0.5
numOfValues = 100000
normal = tf.Variable(tf.random_normal([1,numOfValues], stddev = stddev))
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
import tensorflow as tf
with tf.Session() as sess:
val = tf.nn.softmax([1.0,2.0,3.0,4.0,6.0,1.0,2.0,3.0]).eval()
print(val)
import tensorflow as tf
#Output from a neural network
logits = [1.0,2.0,3.0,4.0,5.0,1.0,1.0]
#Expected output
expected = [1.0,0.0,0.0,0.0,0.0,1.0,1.0]
output1 = tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=expected)
import numpy as np
import tensorflow as tf
MAX_DOCUMENT_LENGTH = 3
vocab_processor = tf.contrib.learn.preprocessing.VocabularyProcessor(
MAX_DOCUMENT_LENGTH)
transform_word = vocab_processor.transform(['hello world', 'welcome my house', 'brown fox', 'have fun', 'having fun'])
list_word = list(transform_word)
x_train = np.array(list_word)
import tensorflow as tf
import numpy
# Parameters
learning_rate = 0.01
training_epochs = 5300
datapoints_count = 100
# Training Data
train_X = []