### TensorFlow学习笔记

TensorFlow学习笔记

0 已关注
26篇博文
• #### 只用TensorFlow的反向传播实现的RNN

rnn.py def simple_rnn(cell,inputs,init_state=None,batch_size=None,dtype=None): state = init_s...

6天前 11:34
49
• #### tensorflow reverse_sequence实例

import tensorflow as tfa = tf.constant([[1,2,3], [1,2,3], [1,2,3]]) l = tf.constant([2,2,2],tf.int64...

2016-10-09 15:40
1504
• #### tf.nn.atrous_conv2d 实例

import numpy as np import tensorflow as tfx_image = tf.placeholder(tf.float32,shape=[5,5]) x = tf.re...

2016-10-24 15:20
1597
• #### TensorFlow 合并 / 连接 数组

import tensorflow as tfa = tf.Variable([4,5,6]) b = tf.Variable([1,2,3])c = tf.concat(0,[a,b]) init_...

2016-12-26 09:22
3582
• #### tf.strided_slice 实例

import tensorflow as tf data = [1,2,3,4,5,6,7,8] x = tf.strided_slice(data,[0],[4]) y = tf.strided_s...

2017-03-02 16:56
4141
• #### tensorflow 点乘 实例

import tensorflow as tfa = tf.constant([[1,2,3],[1,2,3]])b = tf.constant([[2,3,4]])print(a.get_shape...

2017-03-29 15:53
3751
• #### seq2seq 实例

在https://github.com/tensorflow/models/blob/master/tutorials/rnn/translate/translate.py 加入这两个函数def s...

2017-04-10 14:56
1016
• #### tensorflow tf.tile 实例

import tensorflow as tf temp = tf.tile([1,2,3],[2]) temp2 = tf.tile([[1,2],[3,4],[5,6]],[2,3]) with ...

2017-06-22 10:46
3209
• #### tensorflow tf.layers.dense 实例

import tensorflow as tf batch_size = 5 ones = tf.ones([batch_size,20]) logits = tf.layers.dense(ones...

2017-06-22 11:23
6130
• #### tensorflow tf.stack tf.unstack 实例

import tensorflow as tf a = tf.constant([1,2,3]) b = tf.constant([4,5,6]) c = tf.stack([a,b],axis=1)...

2017-06-29 15:39
6322
• #### tf.select 实例

使用tf.select实现eluelu = lambda x: tf.select(x < 0., tf.exp(x) - 1., x) sess.run(tf.gradients(elu(z), z...

2016-10-20 10:53
1281
• #### tensorflow 单机多GPU mnist实例

https://github.com/normanheckscher/mnist-multi-gpu/blob/master/mnist_multi_gpu_batching_train.py自己改的...

2017-07-07 17:49
1126
• #### tf.one_hot 实例

Examples =========Suppose thatpython indices = [0, 2, -1, 1] depth = 3 on_value = ...

2017-08-03 21:29
1160
• #### tensorflow 获取模型所有参数总和数量

def get_num_params(): num_params = 0 for variable in tf.trainable_variables(): shape...

2017-08-07 09:18
509
• #### tf.segment_sum和tf.unsorted_segment_sum实例

import tensorflow as tf c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]]) result = tf.segment_s...

2017-08-27 20:23
370
• #### 给RNN cell加dropout

class SwitchableDropoutWrapper(DropoutWrapper): def __init__(self, cell, is_train, input_keep_pr...

2017-09-12 15:14
205
• #### tensorflow tf.split 和 tf.unstack 实例

import tensorflow as tfA = [[1, 2, 3], [4, 5, 6]] a0 = tf.split(A, num_or_size_splits=3, axis=1) a1 ...

2017-07-06 11:40
3447
• #### tensorflow cosine相似度 实现

def cosine(q,a): pooled_len_1 = tf.sqrt(tf.reduce_sum(q * q, 1)) pooled_len_2 = tf.sqrt(tf.r...

2017-10-12 16:40
294
• #### tensorflow 复合逻辑‘且’和‘或’的实现

import tensorflow as tfn1 = tf.constant(2) n2 = tf.constant(3)n3 = tf.constant(4) n4 = tf.constant(5...

2017-10-12 11:54
223
• #### tensorflow for循环 while循环 实例

import tensorflow as tfn1 = tf.constant(2) n2 = tf.constant(3) n3 = tf.constant(4)def cond1(i, a, b)...

2017-10-12 10:59
1257