上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 29 下一页
摘要: import tensorflow as tf def preporocess(x,y): x = tf.cast(x,dtype=tf.float32) / 255 x = tf.reshape(x,(-1,28 *28)) # 铺平 x = tf.squeeze(x,axis=0) # prin 阅读全文
posted @ 2020-08-16 18:45 山…隹 阅读(631) 评论(0) 推荐(0)
摘要: import tensorflow as tf a = tf.losses.categorical_crossentropy([0,1,0,0],[0.25,0.25,0.25,0.25],from_logits=True) # 前一个参数为标记值,后一个参数为预测值,最后一个参数设为True,输出 阅读全文
posted @ 2020-08-16 11:20 山…隹 阅读(374) 评论(0) 推荐(0)
摘要: import tensorflow as tf logits = tf.random.uniform([1,10],minval=-2,maxval=2) print('logits:',logits) prob = tf.nn.softmax(logits) print('softmax后:',p 阅读全文
posted @ 2020-08-15 17:49 山…隹 阅读(841) 评论(0) 推荐(0)
摘要: import tensorflow as tf x = tf.random.normal((2,3)) # 模拟样本数据 model = tf.keras.Sequential([ # 定义全连接层结构 tf.keras.layers.Dense(4,activation='relu'), # 第一 阅读全文
posted @ 2020-08-15 17:45 山…隹 阅读(601) 评论(0) 推荐(0)
摘要: import tensorflow as tf from tensorflow.keras import optimizers,layers # 定义数据预处理函数 def preprocess(x,y): x = tf.cast(x,dtype=tf.float32) / 255 # 将特征数据转 阅读全文
posted @ 2020-08-12 18:51 山…隹 阅读(758) 评论(0) 推荐(0)
摘要: import tensorflow as tf a = tf.random.normal([3,3]) print('初始a:',a) mask = a > 0 print('mask:',mask) bool_mask = tf.boolean_mask(a,mask) print('bool_m 阅读全文
posted @ 2020-08-12 15:52 山…隹 阅读(548) 评论(0) 推荐(0)
摘要: import tensorflow as tf import numpy as np from tensorflow.keras import datasets, layers, optimizers # 加载手写数字数据 mnist = tf.keras.datasets.mnist (train 阅读全文
posted @ 2020-08-09 18:51 山…隹 阅读(297) 评论(0) 推荐(0)
摘要: import tensorflow as tf import numpy as np import matplotlib.pylab as plt plt.rcParams["font.family"] = 'SimHei' # 将字体改为中文 plt.rcParams['axes.unicode_ 阅读全文
posted @ 2020-08-09 11:39 山…隹 阅读(521) 评论(0) 推荐(0)
摘要: import tensorflow as tf import numpy as np import pandas as pd import matplotlib.pylab as plt import matplotlib as mpl # 读取数据集 TRIN_URL = 'http://down 阅读全文
posted @ 2020-08-04 20:24 山…隹 阅读(494) 评论(0) 推荐(0)
摘要: import tensorflow as tf import numpy as np import matplotlib.pylab as plt # 模拟数据 x = np.array( [137.97, 104.50, 100, 126.32, 79.20, 99.00, 124.0, 114. 阅读全文
posted @ 2020-08-04 16:21 山…隹 阅读(711) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 29 下一页