From 0836a2dda92c3d9e9d4d87e25ae45c30a76e794c Mon Sep 17 00:00:00 2001 From: leemeans <1808577072@qq.com> Date: Sun, 11 Feb 2018 20:48:52 +0800 Subject: [PATCH 1/5] Update 20180206 Programming in Color with ncurses.md --- sources/tech/20180206 Programming in Color with ncurses.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180206 Programming in Color with ncurses.md b/sources/tech/20180206 Programming in Color with ncurses.md index 80d5d9354b..bd31f18bb2 100644 --- a/sources/tech/20180206 Programming in Color with ncurses.md +++ b/sources/tech/20180206 Programming in Color with ncurses.md @@ -1,3 +1,4 @@ +Leemeans translating Programming in Color with ncurses ====== In parts [one][1] and [two][2] of my article series about programming with the ncurses library, I introduced a few curses functions to draw text on the screen, query characters from the screen and read from the keyboard. To demonstrate several of these functions, I created a simple adventure game in curses that drew a game map and player character using simple characters. In this follow-up article, I show how to add color to a curses program. From 5bf1ed5b2fe17eb72aa9a0b30b57b895615cd640 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 11 Feb 2018 23:12:52 +0800 Subject: [PATCH 2/5] PRF:20180206 Simple TensorFlow Examples.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @ghsgz 恭喜你完成了第一篇翻译! --- .../20180206 Simple TensorFlow Examples.md | 154 +++++------------- 1 file changed, 40 insertions(+), 114 deletions(-) diff --git a/translated/tech/20180206 Simple TensorFlow Examples.md b/translated/tech/20180206 Simple TensorFlow Examples.md index c233775b77..be489676b0 100644 --- a/translated/tech/20180206 Simple TensorFlow Examples.md +++ b/translated/tech/20180206 Simple TensorFlow Examples.md @@ -3,94 +3,77 @@ TensorFlow 的简单例子 ![](https://process.filestackapi.com/cache=expiry:max/resize=width:700/compress/XWiMrodDQb2Qg6RxyDDG) -在本次推送中,我们将看一些例子,并从中感受到在定义张量和使用张量做数学计算方面有多么容易,我还会举些别的机器学习相关的例子。 +在本文中,我们将看一些 TensorFlow 的例子,并从中感受到在定义张量tensor和使用张量做数学计算方面有多么容易,我还会举些别的机器学习相关的例子。 -## TensorFlow 是什么? +### TensorFlow 是什么? -TensorFlow 是 Google 为了解决复杂计算耗时过久的问题而开发的一个库。 +TensorFlow 是 Google 为了解决复杂的数学计算耗时过久的问题而开发的一个库。 事实上,TensorFlow 能干许多事。比如: - * 解复杂数学表达式 - * 机器学习技术。你往其中输入一组数据样本用以训练,接着给出另一组数据样本用以预测基于训练的数据的结果。这就是人工智能了! - * 支持 GPU 。你可以使用 GPU (图像处理单元)替代 CPU 以更快的运算。 TensorFlow 有两个版本: CPU 版本和 GPU 版本。 - +* 求解复杂数学表达式 +* 机器学习技术。你往其中输入一组数据样本用以训练,接着给出另一组数据样本基于训练的数据而预测结果。这就是人工智能了! +* 支持 GPU 。你可以使用 GPU(图像处理单元)替代 CPU 以更快的运算。TensorFlow 有两个版本: CPU 版本和 GPU 版本。 开始写例子前,需要了解一些基本知识。 -## 什么是张量? +### 什么是张量? -张量是 TensorFlow 使用的主要的数据块,它很像 TensorFlow 用来处理数据的变量。张量拥有维度和类型的属性。 +张量tensor是 TensorFlow 使用的主要的数据块,它类似于变量,TensorFlow 使用它来处理数据。张量拥有维度和类型的属性。 -维度指张量的行和列数,读到后面你就知道了,可以定义一维张量、二维张量和三维张量。 +维度指张量的行和列数,读到后面你就知道了,我们可以定义一维张量、二维张量和三维张量。 类型指张量元素的数据类型。 -## 定义一维张量 +### 定义一维张量 -可以这样来定义一个张量:创建一个 NumPy (译者注:NumPy 系统是 Python 的一种开源数字扩展,包含一个强大的 N 维数组对象 Array,用来存储和处理大型矩阵 )或者一个 [Python list][1] ,然后使用 tf_convert_to_tensor 函数将其转化成张量。 +可以这样来定义一个张量:创建一个 NumPy 数组(LCTT 译注:NumPy 系统是 Python 的一种开源数字扩展,包含一个强大的 N 维数组对象 Array,用来存储和处理大型矩阵 )或者一个 [Python 列表][1] ,然后使用 `tf_convert_to_tensor` 函数将其转化成张量。 可以像下面这样,使用 NumPy 创建一个数组: + ``` import numpy as np arr = np.array([1, 5.5, 3, 15, 20]) - arr = np.array([1, 5.5, 3, 15, 20]) - ``` 运行结果显示了这个数组的维度和形状。 + ``` import numpy as np - arr = np.array([1, 5.5, 3, 15, 20]) - print(arr) - -print (arr.ndim) - -print (arr.shape) - -print (arr.dtype) - +print(arr.ndim) +print(arr.shape) +print(arr.dtype) ``` -它和 Python list 很像,但是在这里,元素之间没有逗号。 +它和 Python 列表很像,但是在这里,元素之间没有逗号。 + +现在使用 `tf_convert_to_tensor` 函数把这个数组转化为张量。 -现在使用 tf_convert_to_tensor 函数把这个数组转化为张量。 ``` import numpy as np - import tensorflow as tf - arr = np.array([1, 5.5, 3, 15, 20]) - tensor = tf.convert_to_tensor(arr,tf.float64) - print(tensor) - ``` 这次的运行结果显示了张量具体的含义,但是不会展示出张量元素。 要想看到张量元素,需要像下面这样,运行一个会话: + ``` import numpy as np - import tensorflow as tf - arr = np.array([1, 5.5, 3, 15, 20]) - tensor = tf.convert_to_tensor(arr,tf.float64) - sess = tf.Session() - print(sess.run(tensor)) - print(sess.run(tensor[1])) - ``` -## 定义二维张量 +### 定义二维张量 定义二维张量,其方法和定义一维张量是一样的,但要这样来定义数组: @@ -99,227 +82,170 @@ arr = np.array([(1, 5.5, 3, 15, 20),(10, 20, 30, 40, 50), (60, 70, 80, 90, 100)] ``` 接着转化为张量: + ``` import numpy as np - import tensorflow as tf - arr = np.array([(1, 5.5, 3, 15, 20),(10, 20, 30, 40, 50), (60, 70, 80, 90, 100)]) - tensor = tf.convert_to_tensor(arr) - sess = tf.Session() - print(sess.run(tensor)) - ``` 现在你应该知道怎么定义张量了,那么,怎么在张量之间跑数学运算呢? -## 在张量上进行数学运算 +### 在张量上进行数学运算 假设我们有以下两个数组: + ``` arr1 = np.array([(1,2,3),(4,5,6)]) - arr2 = np.array([(7,8,9),(10,11,12)]) - ``` 利用 TenserFlow ,你能做许多数学运算。现在我们需要对这两个数组求和。 使用加法函数来求和: + ``` import numpy as np - import tensorflow as tf - arr1 = np.array([(1,2,3),(4,5,6)]) - arr2 = np.array([(7,8,9),(10,11,12)]) - arr3 = tf.add(arr1,arr2) - sess = tf.Session() - tensor = sess.run(arr3) - print(tensor) - ``` 也可以把数组相乘: + ``` import numpy as np - import tensorflow as tf - arr1 = np.array([(1,2,3),(4,5,6)]) - arr2 = np.array([(7,8,9),(10,11,12)]) - arr3 = tf.multiply(arr1,arr2) - sess = tf.Session() - tensor = sess.run(arr3) - print(tensor) - ``` 现在你知道了吧。 ## 三维张量 -我们已经知道了怎么使用一维张量和二维张量,现在,来看一下三维张量吧,不过这次我们不用数字了,而是用一张 RGB 图片。在这张图片上,每一块像素都由 x,y,z 组合表示。 +我们已经知道了怎么使用一维张量和二维张量,现在,来看一下三维张量吧,不过这次我们不用数字了,而是用一张 RGB 图片。在这张图片上,每一块像素都由 x、y、z 组合表示。 这些组合形成了图片的宽度、高度以及颜色深度。 -首先使用 matplotlib 库导入一张图片。如果你的系统中没有 matplotlib ,可以 [使用pip][2]来安装它。 +首先使用 matplotlib 库导入一张图片。如果你的系统中没有 matplotlib ,可以 [使用 pip][2]来安装它。 将图片放在 Python 文件的同一目录下,接着使用 matplotlib 导入图片: + ``` import matplotlib.image as img - myfile = "likegeeks.png" - myimage = img.imread(myfile) - print(myimage.ndim) - print(myimage.shape) - ``` 从运行结果中,你应该能看到,这张三维图片的宽为 150 、高为 150 、颜色深度为 3 。 你还可以查看这张图片: + ``` import matplotlib.image as img - import matplotlib.pyplot as plot - myfile = "likegeeks.png" - myimage = img.imread(myfile) - plot.imshow(myimage) - plot.show() - ``` 真酷! 那怎么使用 TensorFlow 处理图片呢?超级容易。 -## 使用 TensorFlow 生成或裁剪图片 +### 使用 TensorFlow 生成或裁剪图片 首先,向一个占位符赋值: + ``` myimage = tf.placeholder("int32",[None,None,3]) - ``` 使用裁剪操作来裁剪图像: + ``` cropped = tf.slice(myimage,[10,0,0],[16,-1,-1]) - ``` 最后,运行这个会话: + ``` result = sess.run(cropped, feed\_dict={slice: myimage}) - ``` 然后,你就能看到使用 matplotlib 处理过的图像了。 这是整段代码: + ``` import tensorflow as tf - import matplotlib.image as img - import matplotlib.pyplot as plot - myfile = "likegeeks.png" - myimage = img.imread(myfile) - slice = tf.placeholder("int32",[None,None,3]) - cropped = tf.slice(myimage,[10,0,0],[16,-1,-1]) - sess = tf.Session() - result = sess.run(cropped, feed_dict={slice: myimage}) - plot.imshow(result) - plot.show() - ``` 是不是很神奇? -## 使用 TensorFlow 改变图像 +### 使用 TensorFlow 改变图像 在本例中,我们会使用 TensorFlow 做一下简单的转换。 首先,指定待处理的图像,并初始化 TensorFlow 变量值: + ``` myfile = "likegeeks.png" - myimage = img.imread(myfile) - image = tf.Variable(myimage,name='image') - vars = tf.global_variables_initializer() - ``` 然后调用 transpose 函数转换,这个函数用来翻转输入网格的 0 轴和 1 轴。 + ``` sess = tf.Session() - flipped = tf.transpose(image, perm=[1,0,2]) - sess.run(vars) - result=sess.run(flipped) - ``` 接着你就能看到使用 matplotlib 处理过的图像了。 + ``` import tensorflow as tf - import matplotlib.image as img - import matplotlib.pyplot as plot - myfile = "likegeeks.png" - myimage = img.imread(myfile) - image = tf.Variable(myimage,name='image') - vars = tf.global_variables_initializer() - sess = tf.Session() - flipped = tf.transpose(image, perm=[1,0,2]) - sess.run(vars) - result=sess.run(flipped) - plot.imshow(result) - plot.show() - ``` 以上例子都向你表明了使用 TensorFlow 有多么容易。 @@ -330,7 +256,7 @@ via: https://www.codementor.io/likegeeks/define-and-use-tensors-using-simple-ten 作者:[LikeGeeks][a] 译者:[ghsgz](https://github.com/ghsgz) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 1c5f2ce2b1f9b60fb168bace51f55c176be5103b Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 11 Feb 2018 23:13:53 +0800 Subject: [PATCH 3/5] PUB:20180206 Simple TensorFlow Examples.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @qhsgz 首发地址: https://linux.cn/article-9335-1.html 您的 LCTT 专页地址: https://linux.cn/lctt/ghsgz --- .../tech => published}/20180206 Simple TensorFlow Examples.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180206 Simple TensorFlow Examples.md (100%) diff --git a/translated/tech/20180206 Simple TensorFlow Examples.md b/published/20180206 Simple TensorFlow Examples.md similarity index 100% rename from translated/tech/20180206 Simple TensorFlow Examples.md rename to published/20180206 Simple TensorFlow Examples.md From b99385cbd4ae0601b966049db3b2a60e85142894 Mon Sep 17 00:00:00 2001 From: ChenYi <31087327+cyleft@users.noreply.github.com> Date: Sun, 11 Feb 2018 23:15:32 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=83=BD=E5=8A=9B=E6=9C=89=E9=99=90?= =?UTF-8?q?=EF=BC=8C=E7=BF=BB=E8=AF=91=E4=B8=8D=E6=9D=A5=EF=BC=8C=E9=80=80?= =?UTF-8?q?=E8=AF=91=E9=80=80=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 尴尬了 --- .../20180203 How to print filename with awk on Linux - Unix.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/sources/tech/20180203 How to print filename with awk on Linux - Unix.md b/sources/tech/20180203 How to print filename with awk on Linux - Unix.md index 9be36cb812..d383766764 100644 --- a/sources/tech/20180203 How to print filename with awk on Linux - Unix.md +++ b/sources/tech/20180203 How to print filename with awk on Linux - Unix.md @@ -1,5 +1,3 @@ -translated by cyleft - How to print filename with awk on Linux / Unix ====== From fbfdf21c7532f8cebdf2d7d21250d3230b86a7d2 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 11 Feb 2018 23:23:47 +0800 Subject: [PATCH 5/5] PRF&PUB:20180102 xfs file system commands with examples.md @lujun9972 --- ...0102 xfs file system commands with examples.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) rename {translated/tech => published}/20180102 xfs file system commands with examples.md (93%) diff --git a/translated/tech/20180102 xfs file system commands with examples.md b/published/20180102 xfs file system commands with examples.md similarity index 93% rename from translated/tech/20180102 xfs file system commands with examples.md rename to published/20180102 xfs file system commands with examples.md index 940676dc7a..a797387f75 100644 --- a/translated/tech/20180102 xfs file system commands with examples.md +++ b/published/20180102 xfs file system commands with examples.md @@ -3,11 +3,12 @@ ![Learn xfs commands with examples][1] -在我们另一篇文章中,我带您领略了一下[什么事 xfs,xfs 的相关特性等内容 ][2]。本文我们来看一些常用的 xfs 管理命令。我们将会通过几个例子来讲解如何创建 xfs 文件系统,如何对 xfs 文件系统进行扩容,如何检测并修复 xfs 文件系统。 +在我们另一篇文章中,我带您领略了一下[什么是 xfs,xfs 的相关特性等内容][2]。本文我们来看一些常用的 xfs 管理命令。我们将会通过几个例子来讲解如何创建 xfs 文件系统,如何对 xfs 文件系统进行扩容,如何检测并修复 xfs 文件系统。 ### 创建 XFS 文件系统 `mkfs.xfs` 命令用来创建 xfs 文件系统。无需任何特别的参数,其输出如下: + ``` root@kerneltalks # mkfs.xfs /dev/xvdf meta-data=/dev/xvdf isize=512 agcount=4, agsize=1310720 blks @@ -25,7 +26,7 @@ realtime =none extsz=4096 blocks=0, rtextents=0 ### 调整 XFS 文件系统容量 -你职能对 XFS 进行扩容而不能缩容。我们使用 `xfs_growfs` 来进行扩容。你需要使用 `-D` 参数指定挂载点的新容量。`-D` 接受一个数字的参数,指定文件系统块的数量。若你没有提供 `-D` 参数,则 `xfs_growfs` 会将文件系统扩到最大。 +你只能对 XFS 进行扩容而不能缩容。我们使用 `xfs_growfs` 来进行扩容。你需要使用 `-D` 参数指定挂载点的新容量。`-D` 接受一个数字的参数,指定文件系统块的数量。若你没有提供 `-D` 参数,则 `xfs_growfs` 会将文件系统扩到最大。 ``` root@kerneltalks # xfs_growfs /dev/xvdf -D 256 @@ -41,7 +42,7 @@ realtime =none extsz=4096 blocks=0, rtextents=0 data size 256 too small, old size is 2883584 ``` -观察上面的输出中的最后一行。由于我分配的容量要小于现在的容量。它告诉你不能缩减 XFS 文件系统。你只能对他进行扩展。 +观察上面的输出中的最后一行。由于我分配的容量要小于现在的容量。它告诉你不能缩减 XFS 文件系统。你只能对它进行扩展。 ``` root@kerneltalks # xfs_growfs /dev/xvdf -D 2883840 @@ -59,7 +60,7 @@ data blocks changed from 2883584 to 2883840 现在我多分配了 1GB 的空间,而且也成功地扩增了容量。 - **1GB 块的计算方式:** +**1GB 块的计算方式:** 当前文件系统 bsize 为 4096,意思是块的大小为 4MB。我们需要 1GB,也就是 256 个块。因此在当前块数,2883584 上加上 256 得到 2883840。因此我为 `-D` 传递参数 2883840。 @@ -76,7 +77,9 @@ xfs_repair: /dev/xvdf contains a mounted and writable filesystem fatal error -- couldn't initialize XFS library ``` + 卸载后运行检查命令。 + ``` root@kerneltalks # xfs_repair -n /dev/xvdf Phase 1 - find and verify superblock... @@ -184,10 +187,10 @@ via: https://kerneltalks.com/commands/xfs-file-system-commands-with-examples/ 作者:[kerneltalks][a] 译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:https://kerneltalks.com -[1]:https://c3.kerneltalks.com/wp-content/uploads/2018/01/xfs-commands.png +[1]:https://a3.kerneltalks.com/wp-content/uploads/2018/01/xfs-commands.png [2]:https://kerneltalks.com/disk-management/xfs-filesystem-in-linux/