<jupyter_start><jupyter_text>Linear model training* https://www.tensorflow.org/get_started/get_started<jupyter_code>import tensorflow as tf

# create model
# Model parameters
W = tf.Variable([.3], dtype=tf.float32)
b = tf.Variable([-.3], dtype=tf.float32)
# Model input and output
x = tf.placeholder(tf.float32)
linear_model = W*x + b
y = tf.placeholder(tf.float32)

# creat loss
loss = tf.reduce_sum(tf.square(linear_model - y)) # sum of the squares
# optimizer
optimizer = tf.train.GradientDescentOptimizer(0.01) # learning_rate=0.01
train = optimizer.minimize(loss)

# training data set
x_train = [1, 2, 3, 4]
y_train = [0, -1, -2, -3]


# training loop
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init) # reset values to wrong
for i in range(1000): # train 1000 times
    sess.run(train, {x: x_train, y: y_train})

# evaluate training accuracy
curr_W, curr_b, curr_loss = sess.run([W, b, loss], {x: x_train, y: y_train})
print("W: %s b: %s loss: %s"%(curr_W, curr_b, curr_loss))<jupyter_output>W: [-0.9999969] b: [ 0.99999082] loss: 5.69997e-11
{'fraction_non_alphanumeric': 0.15176908752327747, 'fraction_numerical': 0.05307262569832402, 'mean_word_length': 4.939226519337017, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '589217', 'license': 'MIT', 'n_tokens_mistral': 456, 'n_tokens_neox': 420, 'n_words': 105, 'path': 'tensorflow/tf_basic_train.ipynb', 'repo_name': 'ybdesire/machinelearning', 'size': '1074'}