首頁 文章 tf1

tf1

2021-06-02 17:13  瀏覽數:602  來源:小键人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)