tf1
from sklearn import datasets
from pandas import DataFrame
import pandas as pd
import numpy as np
x_data = datasets.load_iris().data
y_data = datasets.load_iris().target
np.random.seed(9)
np.random.shuffle(x_data)
np.random.seed(9)
np.random.shuffle(y_data)
tf.random.set_seed(9)
x_train = x_data[:-30]
y_train = y_data[:-30]
x_test = x_data[-30:]
y_test = y_data[-30:]
x_train = tf.cast(x_train,tf.float32)
x_test = tf.cast(x_test,tf.float32)
train_db = tf.data.Dataset.from_tensor_slices((x_train,y_train)).batch(32)
test_db = tf.data.Dataset.from_tensor_slices((x_test,y_test)).batch(32)
w1 = tf.Variable(tf.random.truncated_normal([4,3],stddev=0.1, seed=1))
b1 = tf.Variable(tf.random.truncated_normal([3],stddev=0.1,seed=1))
lr = 0.1
train_loss_result = []
test_acc = []
epoch = 500
loss_all = 0