Python tensorflow.foldr() Examples
The following are 13
code examples of tensorflow.foldr().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow
, or try the search function
.
Example #1
Source File: functional_ops_test.py From deep_image_model with Apache License 2.0 | 6 votes |
def testFoldr_Scoped(self): with self.test_session() as sess: with tf.variable_scope("root") as varscope: elems = tf.constant([1, 2, 3, 4, 5, 6], name="data") r = tf.foldr(simple_scoped_fn, elems) # Check that we have the one variable we asked for here. self.assertEqual(len(tf.trainable_variables()), 1) self.assertEqual(tf.trainable_variables()[0].name, "root/body/two:0") sess.run([tf.global_variables_initializer()]) self.assertAllEqual(450, r.eval()) # Now let's reuse our single variable. varscope.reuse_variables() r = tf.foldr(simple_scoped_fn, elems, initializer=10) self.assertEqual(len(tf.trainable_variables()), 1) self.assertAllEqual(1282, r.eval())
Example #2
Source File: tensorflow_backend.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. # Arguments fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph # Returns Tensor with same type and shape as `initializer`. """ return tf.foldr(fn, elems, initializer=initializer, name=name)
Example #3
Source File: functional_ops_test.py From deep_image_model with Apache License 2.0 | 5 votes |
def testFoldr_Simple(self): with self.test_session(): elems = tf.constant([1, 2, 3, 4, 5, 6], name="data") r = tf.foldr(lambda a, x: tf.mul(tf.add(a, x), 2), elems) self.assertAllEqual(450, r.eval()) r = tf.foldr( lambda a, x: tf.mul(tf.add(a, x), 2), elems, initializer=10) self.assertAllEqual(1282, r.eval())
Example #4
Source File: functional_ops_test.py From deep_image_model with Apache License 2.0 | 5 votes |
def testFold_Grad(self): with self.test_session(): elems = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], name="data") v = tf.constant(2.0, name="v") r = tf.foldl( lambda a, x: tf.mul(a, x), elems, initializer=v) r = tf.gradients(r, v)[0] self.assertAllEqual(720.0, r.eval()) r = tf.foldr( lambda a, x: tf.mul(a, x), elems, initializer=v) r = tf.gradients(r, v)[0] self.assertAllEqual(720.0, r.eval())
Example #5
Source File: tensorflow_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. # Arguments fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph # Returns Tensor with same type and shape as `initializer`. """ return tf.foldr(fn, elems, initializer=initializer, name=name)
Example #6
Source File: tensorflow_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. # Arguments fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph # Returns Tensor with same type and shape as `initializer`. """ return tf.foldr(fn, elems, initializer=initializer, name=name)
Example #7
Source File: tensorflow_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. # Arguments fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph # Returns Tensor with same type and shape as `initializer`. """ return tf.foldr(fn, elems, initializer=initializer, name=name)
Example #8
Source File: tensorflow_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. # Arguments fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph # Returns Tensor with same type and shape as `initializer`. """ return tf.foldr(fn, elems, initializer=initializer, name=name)
Example #9
Source File: tensorflow_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. # Arguments fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph # Returns Tensor with same type and shape as `initializer`. """ return tf.foldr(fn, elems, initializer=initializer, name=name)
Example #10
Source File: tensorflow_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. # Arguments fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph # Returns Tensor with same type and shape as `initializer`. """ return tf.foldr(fn, elems, initializer=initializer, name=name)
Example #11
Source File: tensorflow_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. # Arguments fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph # Returns Tensor with same type and shape as `initializer`. """ return tf.foldr(fn, elems, initializer=initializer, name=name)
Example #12
Source File: tensorflow_backend.py From deepQuest with BSD 3-Clause "New" or "Revised" License | 5 votes |
def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. # Arguments fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph # Returns Tensor with same type and shape as `initializer`. """ return tf.foldr(fn, elems, initializer=initializer, name=name)
Example #13
Source File: tensorflow_backend.py From keras-lambda with MIT License | 5 votes |
def foldr(fn, elems, initializer=None, name=None): """Reduce elems using fn to combine them from right to left. # Arguments fn: Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` elems: tensor initializer: The first value used (`elems[-1]` in case of None) name: A string name for the foldr node in the graph # Returns Tensor with same type and shape as `initializer`. """ return tf.foldr(fn, elems, initializer=initializer, name=name)