2019.4.15学习笔记

一,新看到的numpy数组赋值方式

array = np.zeros([2, 3])
row_0 = ['1', '2', '3']
row_1 = [1, 2, 3]
array[0] = row_0
array[1] = row_1
print(array)
# 输出为[[1, 2, 3], [1, 2, 3]]

猜想是numpy数组中有内部的转换机制

二,why use tensorflow gfile ?

官方文档:
File I/O wrappers without thread locking
即:没有线程锁定的文件I/O 包装器
stack overflow大佬:
This comment:

File I/O wrappers without thread locking

…is a particularly unhelpful description for TensorFlow’s tf.gfile module!

The main roles of the tf.gfile module are:

To provide an API that is close to Python’s file objects, and
To provide an implementation based on TensorFlow’s C++ FileSystem API.
The C++ FileSystem API supports multiple file system implementations, including local files, Google Cloud Storage (using a gs:// prefix), and HDFS (using an hdfs:// prefix). TensorFlow exports these as tf.gfile so that you can uses these implementations for saving and loading checkpoints, writing TensorBoard logs, and accessing training data (among other uses). However, if all of your files are local, you can use the regular Python file API without any problem.
原答案链接

三, sys.argv是一个列表,命令行下的参数,其中,第一个就是文件本身。

# test.py
import sys
a = sys.argv[0]
print(a)
# 输出为 test.py

四,初识Tensorflow中层api:Datasets+TFRecord的数据导入

原文链接
几个注意的点

  1. 每个样本的feature信息和值存在字典中,key为feature名,value为feature值
  2. feature需要转变为tensorflow制定的featurel类型中的一个
    int64:tf.train.Feature(int64_list = tf.train.Int64List(value=输入))
    float32:tf.train.Feature(float_list = tf.train.FloatList(value=输入))
    string:tf.train.Feature(bytes_list=tf.train.BytesList(value=输入))
    
    注意:输入必须是list(向量)
    3.tensorflow feature类型值接受list数据,如果处理矩阵或者张量有两种方式:
    1. 转成list类型
    2. 转成string类型
    3. 形状信息:不管那种方式都会使数据丢失形状信息,所以在向该样本中写入feature时应该额外加入shape信息作为额外feature。

五, tf.meshgrid()

meshgrid用于从数组a和b产生网格。生成的网格矩阵A和B大小是相同的。它也可以是更高维的。用法: [A,B]=Meshgrid(a,b),生成size(b)Xsize(a)大小的矩阵A和B。它相当于a从一行重复增加到size(b)行,把b转置成一列再重复增加到size(a)列。
引用自

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值