![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
TensorFlow2
WILD_MIND
这个作者很懒,什么都没留下…
展开
-
TensorFlow2_自定义训练模型
代码如下import tensorflow as tffrom tensorflow import kerasfrom tensorflow.keras import layers,datasets,optimizersimport osos.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'def preprocess(x, y): x = 2*tf.cast(x, dtype=tf.float32)/255.-1 y = tf.cast(y, dt原创 2021-06-25 12:47:17 · 361 阅读 · 0 评论 -
TensorFlow2_网络搭建入门自用
简单结构:import tensorflow as tfnet = tf.keras.layers.Dense(10)# 初始化网络权重net.build(input_shape=(None,4)) # 初始化权重以及偏差print(net.kernel.shape,net.bias.shape) # kernel为权重,bias为偏差net.build(input_shape=(None,20))print(net.kernel.shape,net.bias.shape原创 2021-06-22 00:04:05 · 88 阅读 · 0 评论 -
TensorFlow2_数据一般预处理
一般数据预处理:map每个数据项调用特定函数shuffle打乱顺序 batch设定一次批处理个数tf.data.Dataset.from_tensor_slices数据划分import tensorflow as tfimport keras.datasets as datasetsdef prepare_mnist_features_and_labels(x,y): x = tf.cast(x,tf.float64)/255.0 # 限制在原创 2021-06-21 22:49:49 · 186 阅读 · 0 评论