![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
tensorflow
学习使用tensorflow
automan_huyaoge
对智能机器人,无人驾驶感兴趣
展开
-
tensorflow验证链式法则
import tensorflow as tf # 构建待优化变量 x = tf.constant(1.) w1 = tf.constant(2.) b1 = tf.constant(1.) w2 = tf.constant(2.) b2 = tf.constant(1.) with tf.GradientTape(persistent=True) as tape: # 非tf.Variable类型的张量需要人为设置记录梯度信息 tape.watch([w1, b1, w2, b2]) # .转载 2020-11-06 16:35:04 · 147 阅读 · 0 评论 -
tensorflow求解函数极值
import numpy as np from mpl_toolkits.mplot3d import Axes3D from matplotlib import pyplot as plt import tensorflow as tf def himmelblau(x): # himmelblau函数实现 return (x[0] ** 2 + x[1] - 11) ** 2 + (x[0] + x[1] ** 2 - 7) ** 2 x = np.arang.转载 2020-11-06 16:31:58 · 310 阅读 · 0 评论 -
tensorflow猫狗识别
import os import warnings warnings.filterwarnings("ignore") import tensorflow as tf from tensorflow.keras.optimizers import Adam from tensorflow.keras.preprocessing.image import ImageDataGenerator base_dir = './data/cats_and_dogs' train_dir = os.path.jo.转载 2020-11-06 16:17:31 · 477 阅读 · 0 评论 -
tensorflow手写数字识别
import tensorflow as tf from tensorflow.keras import datasets, layers, optimizers, Sequential, metrics # 设置GPU使用方式 # 获取GPU列表 gpus = tf.config.experimental.list_physical_devices('GPU') if gpus: try: # 设置GPU为增长式占用 for gpu in gpus: tf.c.转载 2020-10-30 14:30:46 · 230 阅读 · 0 评论 -
回归问题
回归问题 import numpy as np # data = [] # for i in range(100): # x = np.random.uniform(3., 12.) # # mean=0, std=0.1 # eps = np.random.normal(0., 0.1) # y = 1.477 * x + 0.089 + eps # data.append([x, y]) # data = np.array(data) # print(data.shape, data)转载 2020-10-30 13:54:49 · 218 阅读 · 0 评论 -
tensorflow入门
加法运算 #%% import tensorflow as tf assert tf.__version__.startswith('2.') # 1.创建输入张量 a = tf.constant(2.) b = tf.constant(4.) # 2.直接计算并打印 print('a+b=',a+b) 自动求导数 import tensorflow as tf # 创建4个张量 a = tf.constant(1.) b = tf.constant(2.) c = tf.constan.转载 2020-10-30 13:44:30 · 245 阅读 · 0 评论