import tensorflow as tf import numpy as np import matplotlib.pyplot as plt # # add layer # def add_layer(inputs, in_size, out_size,n_layer, activation_function = None): layer_name = 'layer%s' % n_layer with tf.name_scope(layer_name): with tf.name_sco…
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt def add_layer(inputs, in_size, out_size, activation_function = None): with tf.name_scope('layer'): with tf.name_scope('Weights'): Weights = tf.Variable(tf.random_normal([in_si…
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt def add_layer(inputs, in_size, out_size, activation_function = None): Weights = tf.Variable(tf.random_normal([in_size, out_size])) # hang lie biases = tf.Variable(tf.zeros([1,…
  一.Matplotlib[结果可视化] #import os #os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' import tensorflow as tf import numpy as np import matplotlib.pyplot as plt #添加一个神经层,定义添加神经层的函数 def add_layer(inputs, in_size, out_size, activation_function = None): Weights =…
bilibili莫烦tensorflow视频教程学习笔记 1.初次使用Tensorflow实现一元线性回归 # 屏蔽警告 import os os.environ[' import numpy as np import tensorflow as tf # create dataset x_data = np.random.rand(100).astype(np.float32) y_data = x_data * 2 + 5 ### create tensorflow structure St…
1,感谢莫烦 2,第一个实例:用tf拟合线性函数 import tensorflow as tf import numpy as np # create data x_data = np.random.rand(100).astype(np.float32) y_data = x_data*0.1 + 0.3 #先创建我们的线性函数目标 #搭建模型 Weights = tf.Variable(tf.random_uniform([1], -1.0, 1.0)) biases = tf.Varia…
1. session对话控制 matrix1 = tf.constant([[3,3]]) matrix2 = tf.constant([[2],[2]]) product = tf.matmul(matrix1,matrix2) #类似于numpy的np.dot(m1,m2) 方法1: sess = tf.Session() result = sess.run(product) print(result) sess.close()>>>[[12]] 方法2: with tf.Sessi…
bilibili莫烦scikit-learn视频学习笔记 1.使用KNN对iris数据分类 from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier # 从datasets中导入iris数据,包含150条样本,每条样本4个feature iris_data = datasets.load_i…
莫烦视频网址 这个代码实现了预测和可视化 import os # third-party library import torch import torch.nn as nn import torch.utils.data as Data import torchvision import matplotlib.pyplot as plt # torch.manual_seed() # reproducible # Hyper Parameters EPOCH = # train the tra…
TensorBoard简介 Tensorflow发布包中提供了TensorBoard,用于展示Tensorflow任务在计算过程中的Graph.定量指标图以及附加数据.大致的效果如下所示, TensorBoard工作机制 TensorBoard 通过读取 TensorFlow 的事件文件来运行.TensorFlow 的事件文件包括了你会在 TensorFlow 运行中涉及到的主要数据.关于TensorBoard的详细介绍请参考TensorBoard:可视化学习.下面做个简单介绍. Tensorf…