Nhập môn TensorFlow bằng Python
Isaiah Hull
Visiting Associate Professor of Finance, BI Norwegian Business School



import tensorflow as tf
# Định nghĩa đầu vào (đặc trưng)
inputs = tf.constant([[1, 35]])
# Định nghĩa trọng số
weights = tf.Variable([[-0.05], [-0.01]])
# Định nghĩa độ chệch (bias)
bias = tf.Variable([0.5])
# Nhân đầu vào (đặc trưng) với trọng số
product = tf.matmul(inputs, weights)
# Định nghĩa tầng dense
dense = tf.keras.activations.sigmoid(product+bias)

import tensorflow as tf
# Định nghĩa tầng đầu vào (đặc trưng)
inputs = tf.constant(data, tf.float32)
# Định nghĩa tầng dense đầu tiên
dense1 = tf.keras.layers.Dense(10, activation='sigmoid')(inputs)
# Định nghĩa tầng dense thứ hai
dense2 = tf.keras.layers.Dense(5, activation='sigmoid')(dense1)
# Định nghĩa tầng đầu ra (dự đoán)
outputs = tf.keras.layers.Dense(1, activation='sigmoid')(dense2)

dense = keras.layers.Dense(10,\
activation='sigmoid')
prod = matmul(inputs, weights)
dense = keras.activations.sigmoid(prod)
Nhập môn TensorFlow bằng Python