1. tf.reuse_default_graph() # 对graph结构图进行清除和重置操作 2.tf.summary.FileWriter(path)构造writer实例化,以便进行后续的graph写入 参数说明:path表示路径 3.writer.add_graph(sess.graph) 将当前参数的graph写入到tensorboard中 参数说明:sess.graph当前的网络结构图 4. summ = tf.summary.merge_all() # 将所有的summary都添加…
keras.layers.embeddings.Embedding(input_dim, output_dim, embeddings_initializer='uniform', embeddings_regularizer=None, activity_regularizer=None, embeddings_constraint=None, mask_zero=False, input_length=None) 输入shape:形如(samples,sequence_length)的2D张…
1. 配套使用: tf.train.Examples将数据转换为二进制,提升IO效率和方便管理 对于int类型 : tf.train.Examples(features=tf.train.Features(feature=tf.train.Feature(int64_list=tf.train.Int64List(value=[value])))) 对于bytes类型: tf.train.Examples(features=tf.train.Features(feature=tf.train.F…
一.关于Attention,关于NMT 未完待续... 以google 的 nmt 代码引入 探讨下端到端: 项目地址:https://github.com/tensorflow/nmt 机器翻译算是深度学习在垂直领域应用最成功的之一了,深度学习在垂直领域的应用的确能解决很多之前繁琐的问题,但是缺乏范化能力不足,这也是各大公司一直解决的问题: 最近开源的模型: lingvo:一种新的侧重于sequence2sequence的框架: bert   :一种基于深度双向Transform的语言模型预训…
首先说明使用的工具和环境:python3.6.8   tensorflow1.14.0   centos7.0(最好用Ubuntu) 关于环境的搭建只做简单说明,我这边是使用pip搭建了python的虚拟环境(virtualenv),并在虚拟环境中安装tensorflow.详细步骤可以查看tensorflow的官网. 训练数据 训练(train.txt)和测试(test.txt)数据,两个文件的分类相同为100个分类,其中test.txt每个类下有200条测试数据,train.txt每个类下有1…
Sentiment analysis in nlp The goal of the program is to analysis the article title is Sarcasm or not, i use tensorflow 2.5 to solve this problem. Dataset download url: https://www.kaggle.com/rmisra/news-headlines-dataset-for-sarcasm-detection/home a…
使用TensorFlow v2.0实现Word2Vec算法计算单词的向量表示,这个例子是使用一小部分维基百科文章来训练的. 更多信息请查看论文: Mikolov, Tomas et al. "Efficient Estimation of Word Representations in Vector Space.", 20131 from __future__ import division, print_function, absolute_import import collect…
一.网络层 keras的层主要包括: 常用层(Core).卷积层(Convolutional).池化层(Pooling).局部连接层.递归层(Recurrent).嵌入层( Embedding).高级激活层.规范层.噪声层.包装层,当然也可以编写自己的层. 对于层的操作 layer.get_weights() #返回该层的权重(numpy array) layer.set_weights(weights)#将权重加载到该层 config = layer.get_config()#保存该层的配置…
经过网上查找,找到了问题所在:在使用keras编程模式是,中间插入了tf.reshape()方法便遇到此问题. 解决办法:对于遇到相同问题的任何人,可以使用keras的Lambda层来包装张量流操作,这是我所做的: embed1 = keras.layers.Embedding(, )(inputs) # embed = keras.layers.Reshape(-,, , )(embed1) # embed = tf.reshape(embed1, [-, , , ]) def reshape…
TensorFlow 高级接口使用简介(estimator, keras, data, experiment) TensorFlow 1.4正式添加了keras和data作为其核心代码(从contrib中毕业),加上之前的estimator API,现在已经可以利用Tensorflow像keras一样方便的搭建网络进行训练.data可以方便从多种来源的数据输入到搭建的网络中(利用tf.features可以方便的对结构化的数据进行读取和处理,比如存在csv中的数据,具体操作可以参考这篇文档):ke…