TensorFlow学习笔记----案例

基础知识整理

x_data = np.random.rand(100).astype(np.float32)
np.random.rand() 返回一个或一组服从“0~1”均匀分布的随机样本值。随机样本取值范围是[0,1),不包括1。
np.random.randn() 返回一个或一组服从标准正态分布的随机样本值。

import tensorflow as tf
import numpy as np
x = np.random.rand(5).astype(np.float32)
print(x)
y = np.random.rand(3,1).astype(np.float32)
print(y)
z = np.random.rand(3,3).astype(np.float32)
print(z)

运行结果:

F:\Anaconda\envs\tuxing1\python.exe E:/tuxing1/text1.py
[ 0.61342514  0.40427819  0.80235332  0.3886812   0.95730197]
[[ 0.92521596]
 [ 0.18034661]
 [ 0.24996562]]
[[ 0.83788085  0.23930655  0.08761514]
 [ 0.16908276  0.62173134  0.82082075]
 [ 0.51067472  0.41088173  0.57261741]]

Process finished with exit code 0

转载:
https://www.jianshu.com/p/049e53f27000

猜你喜欢

转载自blog.csdn.net/weixin_43328054/article/details/105849066