本周的学习有:
1、学习Web前端知识。并且结合 前端课 做了相关网页实践。
2、继续学习深度学习之tensorflow相关的内容。
3、搭建了项目需要的 代码运行环境
1、Web:
- 本周的网页设计是继上周 长师官网 页面设计的补充和完善。花费两周的课余时间,共写了562行代码成功实现。
- 存在的唯一问题就是 还没应用到 轮播图 。
- html代码主体(css代码写在了style标签里):
- 网页结果
2、tensorflow(3):
1、张量(Tensor) : 多维数组(列表) 阶:张量的维数
维数 阶 名字 例子
0-D 0 标量 scalar s=1 2 3
1-D 1 向量 vector v=[1, 2, 3]
2-D 2 矩阵 matrix m=[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
n-D n 张量 tensor t=[ [ [ (n个)
张量可以表示0阶到n阶数组(列表)
2、数据类型
- tf.int, tf.float......
tf.int 32, tf.float 32, tf.float 64
- tf.bool
tf.constant([True, False])
- tf.string
tf.constant("Hello, world!”)
3、如何创建一个Tensor
- 创建一个张量
tf.constant(张量内容, dtype=数据类型(可选))
import tensorflow as tf
a=tf.constant([1,5],dtype=tf.int64)
print(a)
print(a.dtype)
print(a.shape)
- 运行结果:
<tf.Tensor([1,5], shape=(2 , ), dtype=int64)
<dtype: 'int64'>
(2,)
- 将numpy的数据类型转换为Tensor数据类型
tf. convert_to_tensor(数据名,dtype=数据类型(可选))
import tensorflow as tf
import numpy as np
a = np.arange(0, 5)
b = tf.convert_to_tensor( a, dtype=tf.int64)
print(a)
print(b)
运行结果:
[0 1 2 3 4]
tf. Tensor([0 1 2 3 4], shape=( 5 , ), dtype=int64)
- 创建全为0的张量
tf. zeros(维度)
- 创建全为1的张量
tf. ones(维度)
- 创建全为指定值的张量
tf. fill(维度,指定值)
- 维度:
一维 直接写个数
二维 用[行,列]
多维 用[n,m,j,k......]
- 生成正态分布的随机数,默认均值为0,标准差为1
tf. random.normal (维度, mean=均值, stddev=标准差)
- 生成截断式正态分布的随机数
tf. random.truncated_normal(维度,mean=均值,stddev=标准差)
在tf.truncated_normal中如果随机生成数据的取值在(μ-2σ, μ+2σ)之间则重新进行生成,保证了生成值在均值附近。 μ:均值,σ:标准差
3、搭建的环境
在conda环境中安装并在pycharm中运行pytorch+gpu。相关内容参考于CSDN中的文章。