12.12工作日志

12.12 内容:

程序咀嚼:

1. 构筑图gragh, 这一点和python的Numpy不同,graph 为静态的,需要启动一个session。

graph 代表一个计算任务,在模式运行时,整个程序的结构,“图”在会话里被启动。

session将图的节点操作发布到CPU GPU 上,同时提供OP方法(Operation),专门运算的操作节点,每一个操作都是op。


关于tensorflow:

tensorflow  很荣部署到服务器上,这是很多框架做不到的。

大量优秀的项目正在使用tensorflow,可以在多个CPU和GPU下并行。

不足之处:


回归正文:

placeholder: 启动session时程序会真正的运行。python程序的底层为C语言或者其他语言,执行一行脚本,就是有成本的,tensorflow通过计算刘图的方式,优化整个sesion需要执行的代码,还是很有优势的。所以placeholder()函数是在神经网络构建graph时候的模型占位,此时并没有把要输入的数据传入模型,它只会分配必要的内存。等建立session,在会话中,运行模型的时候通过feed_dict()函数 向占位符喂入数据。

学习时,使用了如下示例:

import tensorflow as tf
import numpy as np
 
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)
 
output = tf.multiply(input1, input2)
 
with tf.Session() as sess:
    print(sess.run(output, feed_dict = {input1:[3.], input2: [4.]}))
/home/iser/anaconda3/envs/tensorflow-learning/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:502: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
2020-12-12 21:58:52.727793: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 AVX512F FMA
2020-12-12 21:58:52.966041: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1105] Found device 0 with properties: 
name: GeForce RTX 2080 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.575
pciBusID: 0000:65:00.0
totalMemory: 10.76GiB freeMemory: 9.80GiB
2020-12-12 21:58:52.966082: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1195] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce RTX 2080 Ti, pci bus id: 0000:65:00.0, compute capability: 7.5)
[12.]

 

 
import tensorflow as tf
import numpy as np
 
x = tf.placeholder(tf.float32, shape=(1024, 1024))
y = tf.matmul(x, x)
 
with tf.Session() as sess:
    #print(sess.run(y))  # ERROR:此处x还没有赋值
    rand_array = np.random.rand(1024, 1024)
    print(sess.run(y, feed_dict={x: rand_array})) 
2020-12-12 22:05:01.645065: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 AVX512F FMA
2020-12-12 22:05:01.791864: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1105] Found device 0 with properties: 
name: GeForce RTX 2080 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.575
pciBusID: 0000:65:00.0
totalMemory: 10.76GiB freeMemory: 9.78GiB
2020-12-12 22:05:01.791898: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1195] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce RTX 2080 Ti, pci bus id: 0000:65:00.0, compute capability: 7.5)
[[264.88196 256.2706  258.85715 ... 252.68927 253.2667  256.4321 ]
 [262.64746 253.23653 254.83377 ... 244.76108 246.85315 255.17625]
 [263.8545  260.51007 263.09048 ... 252.3399  256.21805 263.8079 ]
 ...
 [274.35175 263.1493  259.98703 ... 252.62515 259.94763 259.50565]
 [264.54214 254.08362 254.66122 ... 249.22263 252.54991 254.24026]
 [262.92407 254.49603 258.49493 ... 248.71774 258.1954  259.60175]]

2. tensorflow 中使用变量类型

float64

float2

int32

3. 冒号表示  取值范围。

在使用python数组时,被里面的冒号搞晕了,现在做个简单记录

原始数据

import numpy as np
x=np.array([[1,2,3],[5,6,7],[7,8,9]])
x

第一个冒号

如果出现了这样的冒号 x[:,0]
大家可以猜出下返回的结果是什么?

结果是

array([1, 5, 7])

这个冒号代表了获取了x的所有的行数据,之后逗号后面的0,是获取0列。

扩展举例

例如x[:,0:2],返回值为

array([[1, 2], [5, 6], [7, 8]])

如果出现了x[0:2,0:2],返回值为

array([[1, 2], [5, 6]])

第二个冒号

如果出现了这样的冒号 x[:,::-1]

大家可以猜测下返回的结果

 

array([[3, 2, 1], [7, 6, 5], [9, 8, 7]])

 

结果出现了逆序

 

 

 

 

 

 

麒麟操作系统是中国国产操作系统的一种,基于Linux内核。安装 PostgreSQL 数据库到麒麟系统的过程与其它 Linux 发行版大同小异,下面将详细说明步骤。 ### 安装 PostgreSQL 的准备工作: 1. **确认麒麟系统的版本**:不同的麒麟版本,其软件源、包管理工具等可能会有差异,确认好当前使用的麒麟系统版本有助于后续操作的选择。 2. **更新系统**:通过终端运行命令 `sudo apt update` 或者 `dnf check-update` 来更新系统的所有已知补丁及依赖项,保持系统稳定。 ### 获取 PostgreSQL 软件源 对于麒麟系统,通常需要添加额外的软件源以访问 PostgreSQL 的最新发行版。以下是添加 PostgreSQL 源至麒麟系统的示例步骤: ```bash # 对于 Ubuntu 和 Debian 的衍生系统(如 Deepin) echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list # 更新软件仓库索引 sudo apt-get update ``` ### 安装 PostgreSQL 一旦完成上一步的操作,接下来就可以安装 PostgreSQL 数据库了: ```bash # 使用 apt 工具安装 PostgreSQL sudo apt-get install postgresql=12.* -y ``` 注:`12.*` 表示安装 PostgreSQL 12.x 版本系列中的任意一个版本。请替换为具体的版本号以获取特定版本,例如 `12.12`。 ### 初始化数据库实例 安装完成后,通常需要初始化数据库实例: ```bash sudo -u postgres createdb -E UTF8 mydatabase ``` 这里假设你创建了一个名为 `mydatabase` 的新数据库,并指定了字符集为 UTF8。 ### 启动 PostgreSQL 服务 启动 PostgreSQL 服务并设置开机自启: ```bash sudo systemctl start postgresql sudo systemctl enable postgresql ``` ### 登录 PostgreSQL 控制台 登录 PostgreSQL 控制台检查安装状态: ```bash sudo -u postgres psql ``` 此时你应该能够看到 PostgreSQL 控制台提示符,表示 PostgreSQL 成功安装并在服务器上运行。 ### 关闭 PostgreSQL 控制台 关闭控制台返回到用户界面: ```bash \q ``` 至此,您已经在麒麟操作系统上成功安装了 PostgreSQL 12.12。为了安全起见,请记得定期备份数据、监控性能以及根据业务需求调整配置文件(如 `/etc/postgresql/<version>/main/postgresql.conf`)。同时,了解和使用 PostgreSQL 的基本命令对于日常管理和维护非常关键。 ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值