这里的num_units参数并不是指这一层油多少个相互独立的时序lstm,而是lstm单元内部的几个门的参数,这几个门其实内部是一个神经网络,答案来自知乎: class TRNNConfig(object): """RNN配置参数""" # 模型参数 embedding_dim = 100 # 词向量维度 seq_length = 100 # 序列长度 num_classes = 2 # 类别数 vocab_size = 10000 # 词汇表达…
For Tensorflow 1.2 and Keras 2.0, the line tf.contrib.rnn.core_rnn_cell.BasicLSTMCell should be replaced by tf.contrib.rnn.BasicLSTMCell.…
tf.contrib.rnn.static_rnn与tf.nn.dynamic_rnn区别 https://blog.csdn.net/u014365862/article/details/78238807 MachineLP的Github(欢迎follow):https://github.com/MachineLP 我的GitHub:https://github.com/MachineLP/train_cnn-rnn-attention 自己搭建的一个框架,包含模型有:vgg(vgg16,vg…
tf.contrib.rnn.DropoutWrapper Defined in tensorflow/python/ops/rnn_cell_impl.py. def __init__(self, cell, input_keep_prob=1.0, output_keep_prob=1.0, state_keep_prob=1.0, variational_recurrent=False, input_size=None, dtype=None, seed=None): Args: cell…
问题:LSTM的输出值output和state是否是一样的 1. rnn.LSTMCell(num_hidden, reuse=tf.get_variable_scope().reuse)  # 构建单层的LSTM网络 参数说明:num_hidden表示隐藏层的个数,reuse表示LSTM的参数进行复用 2.rnn.DropoutWrapper(cell, output_keep_prob=keep_prob) # 表示对rnn的输出层进行dropout 参数说明:cell表示单层的lstm,o…
一.TensorFlow高层次机器学习API (tf.contrib.learn) 1.tf.contrib.learn.datasets.base.load_csv_with_header 加载csv格式数据 2.tf.contrib.learn.DNNClassifier 建立DNN模型(classifier) 3.classifer.fit 训练模型 4.classifier.evaluate 评价模型 5.classifier.predict 预测新样本 完整代码: from __fut…
在TensorFlow中封装好了一个高级库,tf.contrib.layers库封装了很多的函数,使用这个高级库来开发将会提高效率,卷积函数使用tf.contrib.layers.conv2d,池化函数使用tf.contrib.layers.max_pool2d和tf.contrib.layers.avg_pool2d,全连接函数使用 tf.contrib.layers.fully_connected,下面来看里面封装好的函数接口: 以最复杂的卷积为例,其他的几个函数与之类似: layers.c…
num_units:LSTM cell中的单元数量,即隐藏层神经元数量.use_peepholes:布尔类型,设置为True则能够使用peephole连接cell_clip:可选参数,float类型,如果提供,则在单元输出激活之前,通过该值裁剪单元状态.Initializer:可选参数,用于权重和投影矩阵的初始化器.num_proj:可选参数,int类型,投影矩阵的输出维数,如果为None,则不执行投影.pro_clip:可选参数,float型,如果提供了num_proj>0和proj_clip…
#tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(lstm_size) tf.contrib.rnn.BasicLSTMCell(lstm_size)…
import tensorflow as tf # 22 scope (name_scope/variable_scope) from __future__ import print_function class TrainConfig: batch_size = 20 time_steps = 20 input_size = 10 output_size = 2 cell_size = 11 learning_rate = 0.01 class TestConfig(TrainConfig):…
上代码: import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data #载入数据集 mnist = input_data.read_data_sets("MNIST_data/",one_hot=True) # 输入图片是28*28 n_inputs = 28 #输入一行,一行有28个数据 max_time = 28 #一共28行 lstm_size = 100 #隐层单元 n_c…
1. rnn.BasicLSTMCell(num_hidden) #  构造单层的lstm网络结构 参数说明:num_hidden表示隐藏层的个数 2.tf.nn.dynamic_rnn(cell, self.x, tf.float32) # 执行lstm网络,获得state和outputs 参数说明:cell表示实例化的rnn网络,self.x表示输入层,tf.float32表示类型 3. tf.expand_dim(self.w, axis=0) 对数据增加一个维度 参数说明:self.w表…
在分析训练代码的时候,遇到了,tf.contrib.crf.crf_log_likelihood,这个函数,于是想简单理解下: 函数的目的:使用crf 来计算损失,里面用到的优化方法是:最大似然估计 使用方法: tf.contrib.crf.crf_log_likelihood(inputs, tag_indices, sequence_lengths, transition_params=None) See the guide: CRF (contrib) Computes the log-l…
TensorFlow高层次机器学习API (tf.contrib.learn) 1.tf.contrib.learn.datasets.base.load_csv_with_header 加载csv格式数据 2.tf.contrib.learn.DNNClassifier 建立DNN模型(classifier) 3.classifer.fit 训练模型 4.classifier.evaluate 评价模型 5.classifier.predict 预测新样本 完整代码: 1 from __fut…
tf.nn.l2_loss()与tf.contrib.layers.l2_regularizerd()都是TensorFlow中的L2正则化函数,tf.contrib.layers.l2_regularizerd()函数在tf 2.x版本中被弃用了. 两者都能用来L2正则化处理,但运算有一点不同. import tensorflow as tf sess = InteractiveSession() a = tf.constant([1, 2, 3], dtype=tf.float32) b =…
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt BATCH_START = 0 TIME_STEPS = 20 BATCH_SIZE = 50 INPUT_SIZE = 1 OUTPUT_SIZE = 1 CELL_SIZE = 10 LR = 0.006 BATCH_START_TEST = 0 def get_batch(): global BATCH_START, TIME_STEPS #…
#!/usr/bin/env python # -*- coding: utf-8 -*- import tensorflow as tf import numpy as np params=np.random.normal(loc=0.0,scale=1.0,size=[10,10]) encoder_inputs=tf.placeholder(dtype=tf.int32,shape=[10,10]) decoder_inputs=tf.placeholder(dtype=tf.int32,…
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt BATCH_START = 0 TIME_STEPS = 20 BATCH_SIZE = 50 INPUT_SIZE = 1 OUTPUT_SIZE = 1 CELL_SIZE = 10 LR = 0.006 BATCH_START_TEST = 0 def get_batch(): global BATCH_START, TIME_STEPS x…
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', one_hot=True) lr=0.001 training_iters=100000 batch_size=128 n_inputs=28 n_steps=28 n_hidden_units=128 n_classes=10 x=tf…
TF.Contrib,开源社区贡献,新功能,内外部测试,根据反馈意见改进性能,改善API友好度,API稳定后,移到TensorFlow核心模块.生产代码,以最新官方教程和API指南参考. 统计分布.TF.contrib.ditributions模块,Bernoulli.Beta.Binomial.Gamma.Ecponential.Normal.Poisson.Uniform等统计分布,统计研究.应用中常用,各种统计.机器学习模型基石,概率模型.图形模型依赖. 每个不同统计分布不同特征.函数,同…
tf.contrib.legacy_seq2seq.basic_rnn_seq2seq 函数 example 最简单实现 函数文档:https://www.tensorflow.org/api_docs/python/tf/contrib/legacy_seq2seq/basic_rnn_seq2seq import tensorflow as tf import numpy as np steps=10 batch_size=10 input_size=10 encoder_inputs =…
这一节,介绍TensorFlow中的一个封装好的高级库,里面有前面讲过的很多函数的高级封装,使用这个高级库来开发程序将会提高效率. 我们改写第十三节的程序,卷积函数我们使用tf.contrib.layers.conv2d(),池化函数使用tf.contrib.layers.max_pool2d()和tf.contrib.layers.avg_pool2d(),全连接函数使用tf.contrib.layers.fully_connected(). 一 tf.contrib.layers中的具体函数…
tf.contrib.layers.fully_connected 添加完全连接的图层. tf.contrib.layers.fully_connected(    inputs,    num_outputs,    activation_fn=tf.nn.relu,    normalizer_fn=None,    normalizer_params=None,    weights_initializer=initializers.xavier_initializer(),    wei…
tf.contrib.learn.preprocessing.VocabularyProcessor (max_document_length, min_frequency=0, vocabulary=None, tokenizer_fn=None) 参数: max_document_length: 文档的最大长度.如果文本的长度大于最大长度,那么它会被剪切,反之则用0填充. min_frequency: 词频的最小值,出现次数小于最小词频则不会被收录到词表中. vocabulary: Cate…
在oneActivity中实现跳转到MainActivity //intent 用来跳转另外一个MainActivity,bundle传值到MainActivity         Intent MainActivity = new Intent();         MainActivity .setClass(this,MainActivity.class);         Bundle bundle = new Bundle(); //该类用作携带数据             bundl…
J2EE里面的2是什么意思 J2SE,J2SE,J2ME中2的含义要追溯要1998年.1998年Java 1.2版本发布,1999年发布Java 1.2的标准版,企业版,微型版三个版本,为了区分这三个版本,分别叫做Java2SE,Java2EE,Java2ME,简称J2SE,J2EE,J2ME.故,2的含义为1.2版本.但是,这种叫法已经在2005年Java 1.6发布后取消,J2EE更名为Java EE,J2SE更名为Java SE,J2ME更名为Java ME.所以,现在的J2EE等叫法是0…
当grid里面有gridSelect组件的时候,gridSelect里面的bind-ref是对应的数据库存入字段(int类型),bind-labelRef是对应的计算字段(视图里面的),而option里面的data对应的是下拉显示的数据源,value是先啦显示数据源对应的id号,label是下拉显示数据源的名称.        而要想grid里面显示汉字在右键添加列的时候不选择对应数据库的字段而选择对应的计算字段,其他不变,就能正常显示汉字了.…
dede 发布文章的时候会在里面的标签中添加一些style 属性,现在改网站想去掉这些属性和里面的值,因为文章太多所以就用下面的方法 \include\arc.listview.class.php 在这个文件中的240行左右有个 '//设置全局环境变量 '  ,在这部分内容下面添加以下这句话一句就OK了! // 过滤掉样式表  $this->Fields['body'] = preg_replace("/style=.+?[*|\"]/i","",$…
要求:手机端打开某个页面的详细信息,因为网速或者别的原因,响应太慢,因为图片大的原因,希望先进来,图片在网页运行的情况再慢慢加载(jquer延迟加载) http://www.w3cways.com/1765.html()  困难:因为页面的图片是用编辑器加进去的        :图片与文字存到数据库的字段中 :实现思路:从数据库中读取这个字段,把字段里面的src替换成lazyload 然后再返回给页面…
IO流根据处理对象的不同分为节点流和处理流. 直接对文件进行处理的流为节点流: 对流进行包装从而实现对文件的优化处理的流为处理流. 节点流类型: 可以看出,节点流主要分这几大类: 文件流 文件流构造方法概要(FileInputStream和FileOutputStream构造相同于对应的Reader和Writer): 数组流 字符串流 管道流 节点流里面的Reader/Writer和InputStream/OutputStream分别继承自相应的父类. 处理流类型: 处理流的几个常用类: 缓冲流…