首页 文章 tf1

tf1

2021-06-02 17:13  浏览数:592  来源:小键人879686    

import tensorflow as tf
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



声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)