<jupyter_start><jupyter_text>Exemplo Rede Neural com TF<jupyter_code>n_features = 10
n_dense_neurons = 3
x = tf.placeholder(tf.float32, (None, n_features))
W = tf.Variable(tf.random_normal([n_features, n_dense_neurons]))
print(W)

b = tf.Variable(tf.ones([n_dense_neurons]))
b
xW = tf.matmul(x, W)
z = tf.add(xW, b)
a = tf.sigmoid(z)
init = tf.global_variables_initializer()
with tf.Session() as sess:
    sess.run(init)
    layer_out = sess.run(a, feed_dict={x:np.random.random([1, n_features])})
print(layer_out)<jupyter_output>[[0.07333042 0.8824642  0.95136017]]<jupyter_text>Simple Regression Exemple<jupyter_code>x_data = np.linspace(0,10,10) + np.random.uniform(-1.5,1.5,10)
x_data
y_label = np.linspace(0, 10, 10) + np.random.uniform(-1.5, 1.5, 10)
y_label
plt.plot(x_data, y_label, '*')
# y = mx + b
np.random.rand(2)
m = tf.Variable(0.91)
b = tf.Variable(0.87)
error = 0

for x,y in zip(x_data, y_label):
    y_hat = m*x + b
    
    error += (y-y_hat)**2
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.001)
train = optimizer.minimize(error)
init = tf.global_variables_initializer()
with tf.Session() as sess:
    
    sess.run(init)
    
    training_steps = 1
    
    for i in range(training_steps):
        sess.run(train)
        
    final_slope, final_intercept = sess.run([m, b])
x_test = np.linspace(-1, 11, 10)

# y = m*x + b
y_pred_plot = final_slope * x_test + final_intercept

plt.plot(x_test, y_pred_plot, 'r')
plt.plot(x_data, y_label, '*')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15695364238410597, 'fraction_numerical': 0.048344370860927154, 'mean_word_length': 4.47463768115942, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '447979', 'license': 'MIT', 'n_tokens_mistral': 704, 'n_tokens_neox': 652, 'n_words': 115, 'path': 'perceptron.ipynb', 'repo_name': 'eduardagoulart/rede_neural', 'size': '1510'}