Example #1
0
# -*- coding: utf-8 -*-
#!/usr/bin/python

import tensorflow as tf
import numpy as np
import tfutil

x = [[[[1, 2, 3, 4]]]]

const1 = tf.constant(np.array(x), dtype=tf.int32)
print(const1)
print(tf.shape(const1))
tfutil.print_constant(const1)

blocksize = 2
dts_const1 = tf.depth_to_space(const1, blocksize)
print(dts_const1)
print(tf.shape(dts_const1))
tfutil.print_operation_value(dts_const1)

x = [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]
const2 = tf.constant(np.array(x), dtype=tf.int32)
print(const2)
print(tf.shape(const2))
tfutil.print_constant(const2)

blocksize = 2
dts_const2 = tf.depth_to_space(const2, blocksize)
print(dts_const2)
print(tf.shape(dts_const2))
tfutil.print_operation_value(dts_const2)
Example #2
0
# -*- coding: utf-8 -*-
#!/usr/bin/python

import tensorflow as tf
import tfutil

if __name__ == '__main__':
    const = tf.ones([2, 3], tf.int32)
    tfutil.print_constant(const)

# -*- coding: utf-8 -*-
#!/usr/bin/python

import tensorflow as tf
import tfutil

if __name__ == '__main__':
    norm = tf.random_uniform([2, 3], name="var")
    tfutil.print_constant(norm)
Example #4
0
# -*- coding: utf-8 -*-
#!/usr/bin/python

import tensorflow as tf
import tfutil

if __name__ == '__main__':
    norm1 = tf.random_normal([2, 3], mean=-1, stddev=4)
    tfutil.print_constant(norm1)

    norm2 = tf.random_normal([2, 3], seed=1234)
    tfutil.print_constant(norm2)
Example #5
0
import numpy as np
import tfutil
'''
# merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...]
# Scalar indices:
  merged[indices[m], ...] = data[m][...]
# Vector indices:
  merged[indices[m][i], ...] = data[m][i, ...]
merged.shape = [max(indices)] + constant
'''

x = [[1, 2], [3, 4]]
const1 = tf.constant(np.array(x))
print(const1)
print(tf.shape(const1))
tfutil.print_constant(const1)

indice = [[0, 1], [2, 3]]
dys_const1 = tf.dynamic_stitch(indice, const1)
print(dys_const1[0])
print(tf.shape(dys_const1[0]))
tfutil.print_operation_value(dys_const1[0])

x = [[1, 2], [3, 4]]
const1 = tf.constant(np.array(x))
print(const1)
print(tf.shape(const1))
tfutil.print_constant(const1)

y = [1, 1]
row_to_add = tf.constant(np.array(y))
Example #6
0
# -*- coding: utf-8 -*-
#!/usr/bin/python

import tensorflow as tf
import tfutil

const1 = tf.constant([1, 2, 3, 4, 5, 6, 7, 8, 9])
print(const1)
tfutil.print_constant(const1)
rs_const1 = tf.reshape(const1, [3, 3])
print(rs_const1)
tfutil.print_operation_value(rs_const1)

const2 = tf.constant([[[1, 1], [2, 2]], [[3, 3], [4, 4]]])
print(const2)
tfutil.print_constant(const2)
rs_const2 = tf.reshape(const2, [2, 4])
print(rs_const2)
tfutil.print_operation_value(rs_const2)

const3 = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]],
                      [[5, 5, 5], [6, 6, 6]]])
print(const3)
tfutil.print_constant(const3)
rs_const3 = tf.reshape(const3, [-1])
print(rs_const3)
tfutil.print_operation_value(rs_const3)

const4 = tf.constant([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6])
print(const4)
tfutil.print_constant(const4)
Example #7
0
# -*- coding: utf-8 -*-
#!/usr/bin/python

import tensorflow as tf
import tfutil

if __name__ == '__main__':
    const = tf.constant([[1, 2], [3, 4], [5, 6]])
    tfutil.print_constant(const)
    shuff = tf.random_shuffle(const)
    tfutil.print_constant(shuff)
Example #8
0
# -*- coding: utf-8 -*-
#!/usr/bin/python

import tensorflow as tf
import numpy as np
import tfutil

x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
const1 = tf.constant(np.array(x), dtype=tf.int32)
print(const1)
print(tf.shape(const1))
tfutil.print_constant(const1)

idx_const2 = tf.constant([1, 0, 2])
print(idx_const2)
print(tf.shape(idx_const2))
tfutil.print_constant(idx_const2)

idx_flattened = tf.range(0, const1.shape[0]) * const1.shape[1] + idx_const2
print(idx_flattened)
print(tf.shape(idx_flattened))
tfutil.print_constant(idx_flattened)

# partial code 1
print(const1.shape[0])
tmp1 = tf.range(0, const1.shape[0])
print(tmp1)
print(tf.shape(tmp1))
tfutil.print_constant(tmp1)

# partial code 2