tensorflow 1.13 使用记录
由于生产环境目前还以1.13版本为主, 而google为了推进2.x已经下架了大部分官方教程, 这里简单做一些记录
1. name_scope / variable_scope
注意 tf.get_variable 不受 name_scope 影响
https://blog.csdn.net/u012609509/article/details/80045529
2. SavedModel模型的保存与加载 (pb格式,跨语言部署)
https://blog.csdn.net/mogoweb/article/details/83021524
3. difference between tf.initialize_all_variables() and tf.initialize_local_variables()?
LOCAL_VARIABLES: the subset of Variable objects that are local to each machine. Usually used for temporarily variables,
like counters. Note: use tf.contrib.framework.local_variable to add to this collection.
3. API
tf.einsum(), einsum表达式描述几乎所有矩阵运算
https://zhuanlan.zhihu.com/p/44954540
tf.tile() , 按某些维度复制 tensor
https://blog.csdn.net/xwd18280820053/article/details/72867818
batch_norm / tf.control_dependencies / tf.GraphKeys.UPDATE_OPS
https://blog.csdn.net/huitailangyz/article/details/85015611
L2正则化和collection,tf.GraphKeys.REGULARIZATION_LOSSES
https://www.jianshu.com/p/5264ff3b3db3
4. sparse 2 dense
# split enum_features_sps = tf.strings.split(tf.reshape(enum_feat_strings, [-1]), sep=user_params["features_sep"]) # dense shape [batch, feature*seqlen] enum_features = tf.sparse_to_dense( enum_features_sps.indices, [user_params["batch_size"], user_params["n_enumfeatures"] * user_params["n_seq_length"]], enum_features_sps.values, default_value="yahaha" )
5. mask
mask = tf.cast(tf.not_equal(enum_features, user_params["features_pad"]), tf.int32)
6. Unquoted fields cannot have quotes/CRLFs inside
use_quote_delim 参数, 设置为True,会把双引号当成引用,在使用tf.decode_csv读取文件的时候如果某一行有双引号会报错,
如果设置为False会把双引号当做为一个普通的字符串变量,在这里读取不会报错

浙公网安备 33010602011771号