as np # Create Sample Data trainX = np.linspace(-1, 1, 101) trainY = 3 * trainX + np.random.randn(*trainX.shape) * 0.33 # Place Holder X = tf.placeholder("float") Y = tf.placeholder("float") # Build a model w = tf.Variable(0.0, name="weights") y_model = tf.multiply(X, w) cost = (tf.pow(Y-y_model, 2)) train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost) # Train a model init= tf.global_variables_initializer() with tf.Session() as sess: sess.run(init) for i in range(100): for (x, y) in zip(trainX, trainY): sess.run(train_op, feed_dict={X: x, Y: y}) print(sess.run(w))
by Default (2) Keras as the high-level API (3) API Cleanup (4) TF datasets (5) You can still run TensorFlow 1.x code with 2.0 release https://levelup.gitconnected.com/5-important-changes-coming-with-tensorflow-2-0-e6bb172c5fdf