
TensorFlow
文章平均质量分 53
NNNJY
这个作者很懒,什么都没留下…
展开
-
TensorFlow进阶例子二
还是鸢尾花分类,但多了参数优化器、激活函数、loss曲线、acc曲线、时间等:# 利用鸢尾花数据集,实现前向传播、反向传播,可视化loss曲线# 导入所需模块import tensorflow as tffrom sklearn import datasetsfrom matplotlib import pyplot as pltimport numpy as npimport time ##1### 导入数据,分别为输入特征和标签x_data = datasets.load_iri原创 2021-03-23 20:40:20 · 121 阅读 · 0 评论 -
TensorFlow基础例子一
神经网络实现鸢尾花分类不需要另外下载数据集,在sklearn包中就已经有数据集。代码虽然简单,但将神经网络大部分步骤都涵盖进来了,基础且关键:# -*- coding: UTF-8 -*-# 利用鸢尾花数据集,实现前向传播、反向传播,可视化loss曲线# 导入所需模块import tensorflow as tffrom sklearn import datasetsfrom matplotlib import pyplot as pltimport numpy as np# 导入数据原创 2021-03-23 13:39:51 · 221 阅读 · 1 评论 -
TensorFlow和numpy常用函数(二)
TensorFlow常用函数二1.条件语句where2.随机数生成0~1之间np.random.RandomState.rand3.以行的方式链接数组vstack4.生成坐标点np.mgrid、ravel、np.c_1.条件语句where条件语句为真返回A,条件语句为假返回B:tf.where(条件语句, 真返回A, 假返回B)例如求两张量每个元素的最大值:import tensorflow as tfa = tf.constant([1, 2, 3, 1, 1])b = tf.cons原创 2021-03-22 17:15:11 · 289 阅读 · 0 评论 -
TensorFlow基础常用函数(一)
TensorFlow常用函数1.constant:创建张量:张量是TensorFlow里最常用的数据结构,可以理解为任意维的数组。调用方式为:tf.constant(张量内容, dtype=数据类型(可选))如创建一个一阶张量(即一维数组),里面只有两个元素1和5:a = tf.constant([1, 5], dtype=tf.int64)print("a:", a)print("a.dtype:", a.dtype)print("a.shape:", a.shape)输出结果原创 2021-03-20 20:51:46 · 766 阅读 · 0 评论