import tensorflow as tf
import numpy as np
x_data = np.loadtxt('exam-result.csv', delimiter=',', usecols=[3], skiprows=1)
y_data = np.loadtxt('exam-result.csv', delimiter=',', usecols=[1], skiprows=1)
# Try to find values for W and b that compute y_data = W * x_data + b
# (We know that W should be 0.1 and b 0.3, but TensorFlow will
# figure that out for us.)
W = tf.Variable(tf.zeros([1]))
b = tf.Variable(tf.zeros([1]))
y = W * x_data + b
# Minimize the mean squared errors.
loss = tf.reduce_mean(tf.square(y - y_data))
optimizer = tf.train.GradientDescentOptimizer(0.01)
train = optimizer.minimize(loss)
# Before starting, initialize the variables. We will 'run' this first.
init = tf.global_variables_initializer()
# Launch the graph.
sess = tf.Session()
sess.run(init)
# Fit the line.
for step in range(2001):
sess.run(train)
if step % 200 == 0:
print(step, sess.run(W), sess.run(b))
# Close the Session when we're done.
sess.close()
◼️1CPU Using up to 1 cpu(s) for the stress calculation.
Using up to 1 cpu(s) for the symmetric stiffness/mass contributions.
Factoring the system of equations using the symmetric spooles solver Using up to 1 cpu(s) for spooles.
Using up to 1 cpu(s) for the stress calculation. average force= 16.144929 time avg. forc= 12.096706 largest residual force= 0.000454 in node 1756 and dof 2 largest increment of disp= 1.282442e-01 largest correction to disp= 9.891491e-06 in node 609 and dof 2
convergence
the increment size exceeds the remainder of the step and is decreased to 0.000000e+00 Using up to 1 cpu(s) for the stress calculation.
Job finished
real 0m21.924s user 0m19.113s sys 0m0.643s
◼️4CPU Using up to 4 cpu(s) for the stress calculation.
Using up to 4 cpu(s) for the symmetric stiffness/mass contributions.
Factoring the system of equations using the symmetric spooles solver Using up to 4 cpu(s) for spooles.
Using up to 4 cpu(s) for the stress calculation. average force= 16.144929 time avg. forc= 12.096706 largest residual force= 0.000454 in node 1756 and dof 2 largest increment of disp= 1.282442e-01 largest correction to disp= 9.891491e-06 in node 609 and dof 2
convergence
the increment size exceeds the remainder of the step and is decreased to 0.000000e+00 Using up to 4 cpu(s) for the stress calculation.