Example #1
0
 def initialize_param(self):
     sd = math.sqrt(1.0 / self.shape[0])
     self.param = tfg.Variable(tff.get_truncated_normal(shape=self.shape,
                                                        mean=self.mean,
                                                        sd=sd,
                                                        low=-sd,
                                                        upp=sd), name=self.name)
Example #2
0
 def initialize_param(self):
     self.param = tfg.Variable(tff.get_truncated_normal(shape=self.shape,
                                                        mean=self.mean,
                                                        sd=self.sd,
                                                        low=self.low,
                                                        upp=self.upp),
                               name=self.name)
Example #3
0
 def initialize_param(self):
     init_range = np.sqrt(6.0 / (self.shape[0] + self.shape[1]))
     self.param = tfg.Variable(
         (init_range -
          (-init_range) * np.random.random_sample(size=self.shape) +
          (-init_range)),
         name=self.name)
Example #4
0
 def initialize_param(self):
     if len(self.shape) == 2:
         sd = math.sqrt(2.0 / (self.shape[0] + self.shape[1]))
     else:
         sd = math.sqrt(2.0 / self.shape[0])
     self.param = tfg.Variable(np.random.uniform(low=-sd,
                                                 high=sd,
                                                 size=self.shape), name=self.name)
Example #5
0
 def initialize_param(self):
     sd = math.sqrt(2.0 / (self.shape[1] * self.shape[2] * self.shape[3]))
     self.param = tfg.Variable(tff.get_truncated_normal(shape=self.shape,
                                                        mean=0.0,
                                                        sd=sd,
                                                        low=-sd,
                                                        upp=sd),
                               name=self.name)
Example #6
0
    def initialize_param(self):
        if len(self.shape) == 2:
            sd = math.sqrt(4.0 / (self.shape[0] + self.shape[1]))
        else:
            sd = math.sqrt(2.0 / self.shape[0])

        self.param = tfg.Variable(np.random.normal(loc=0.0,
                                                   scale=sd,
                                                   size=self.shape),
                                  name=self.name)
Example #7
0
 def initialize_param(self):
     if len(self.shape) == 2:
         sd = math.sqrt(2.0 / (self.shape[0] + self.shape[1]))
     else:
         sd = math.sqrt(2.0 / self.shape[0])
     self.param = tfg.Variable(tff.get_truncated_normal(shape=self.shape,
                                                        mean=self.mean,
                                                        sd=sd,
                                                        low=-sd,
                                                        upp=sd), name=self.name)
Example #8
0
 def initialize_param(self):
     self.param = tfg.Variable(np.random.random(size=self.shape),
                               name=self.name)
Example #9
0
 def initialize_param(self):
     self.param = tfg.Variable(np.random.normal(loc=self.mean,
                                                scale=self.sd,
                                                size=self.shape),
                               name=self.name)
Example #10
0
 def initialize_param(self):
     self.param = tfg.Variable(np.ones(shape=self.shape) * 0.1,
                               name=self.name)
Example #11
0
 def initialize_param(self):
     self.param = tfg.Variable(np.random.randn(self.shape[0],
                                               self.shape[1]),
                               name=self.name)
Example #12
0
 def initialize_param(self):
     self.param = tfg.Variable(np.zeros(shape=self.shape), name=self.name)
Example #13
0
 def initialize_param(self):
     self.param = tfg.Variable(self.value, name=self.name)
Example #14
0
from tensorflux import graph as tfg
from tensorflux import session as tfs
import networkx as nx
import matplotlib.pyplot as plt

g = tfg.Graph()
g.initialize()

# Create variables
w = tfg.Variable(5.0, name="a")
b = tfg.Variable(-1.0, name="b")

# Create placeholder
x = tfg.Placeholder(name="x")

## Create hidden node y
#y = tfg.Matmul(A, x, name="y")
#
## Create output node z
#z = tfg.Add(y, b, name="z")

#nx.draw_networkx(g, with_labels=True)
#plt.show(block=True)

session = tfs.Session()
output = session.run(z, {x: 1.0})
output = session.run(z, {x: 2.0})
print(output)
Example #15
0
 def initialize_param(self):
     #print (self.shape[0], self.shape[1] )
     self.param = tfg.Variable(np.random.uniform(low=-1,
                                                 high=1,
                                                 size=self.shape),
                               name=self.name)
Example #16
0
from tensorflux import graph as tfg
from tensorflux import session as tfs
import networkx as nx
import matplotlib.pyplot as plt

# g= graph.Graph()
g = tfg.Graph()
g.initialize()

# Create variables
a = tfg.Variable(5.0, name='a')
b = tfg.Variable(1.0, name='b')

# Create placeholder
x = tfg.Placeholder(name='x')

# Create hidden node y
y = tfg.Mul(a, x, name="y")

# Create output node z
z = tfg.Add(y, b, name="z")

#nx.draw_networkx(g, with_labels=True)
#plt.show(block=True)

session = tfs.Session()
output = session.run(z, {x: 1.0})
print(output)

print(z.input_nodes[0], z.input_nodes[1])
print(z.output)
Example #17
0
# placeholder 생성
x = tfg.Placeholder(name = "X")

# Create hidden node y
y = tfg.Mul(a, x, name="y")

# Create output node z
z = tfg.Add(y, b, name="z") #z : operation

session = tfs.Session()
output = session.run(z, {x: 1.0})
print(output)
"""

# Create variables
A = tfg.Variable([[1, 0], [0, -1]], name="a")
b = tfg.Variable([1, 1], name="b")

# Create placeholder
x = tfg.Placeholder(name="x")

# Create hidden node y
y = tfg.Matmul(A, x, name="y")  #a, x, b가 행렬이기 때문에 mul이 아니라 matmul

# Create output node z
z = tfg.Add(y, b, name="z")

nx.draw_networkx(g, with_labels=True)
plt.show(block=True)

session = tfs.Session()
Example #18
0
from tensorflux import graph as tfg  # graph 모듈을 객체화
from tensorflux import session as tfs
import networkx as nx
import matplotlib.pyplot as plt

g = tfg.Graph()
g.initialize()

#--------------
# Create variables
a = tfg.Variable(5.0, name="a")
b = tfg.Variable(1.0, name="b")

# Create placeholder
x = tfg.Placeholder(name="x")

# Create hidden node y
y = tfg.Mul(a, x, name="y")

# Create output node z
z = tfg.Add(y, b, name="z")

session = tfs.Session()
output = session.run(z, {x: 1.0})  # z:operation
print(output)
print()
print("-------------------")
#--------------
# Create variables
# Not scalar, list
A = tfg.Variable([[1, 0], [0, -1]], name="A")
Example #19
0
import tensorflux.graph as tfg
import tensorflux.session as tfs

apple_price = 100
apple_num = 2

orange_price = 150
orange_num = 3

tax = 1.1

g = tfg.Graph()

# Create variables
a = tfg.Variable(apple_price, name="a")
b = tfg.Variable(apple_num, name="b")

c = tfg.Variable(orange_price, name="c")
d = tfg.Variable(orange_num, name="d")

e = tfg.Variable(tax, name="e")

# Create Mul operation node
f = tfg.Mul(a, b, name="f")
g = tfg.Mul(c, d, name="g")

# Create Add operation node
h = tfg.Add(f, g, name="h")

# Create Mul operation node
i = tfg.Mul(h, e, name="i")
Example #20
0
 def initialize_param(self):
     sd = math.sqrt(1.0 / self.shape[0])
     self.param = tfg.Variable(np.random.uniform(low=-sd,
                                                 high=sd,
                                                 size=self.shape), name=self.name)
Example #21
0
from tensorflux import graph as tfg
from tensorflux import session as tfs

#import networkx as nx
#import matplotlib.pyplot as plt

g = tfg.Graph()  # 컴퓨테이션 그래프 클래스를 생성
#g.initialize() # 컴퓨테이션 그래프 클래스를 초기화
#"""
# Create variables
a = tfg.Variable(5.0, name="a")  #변수 클래스 a를 생성하고 초기화
b = tfg.Variable(-1.0, name="b")  #변수 클래스 b를 생성하고 초기화

# Create placeholder
x = tfg.Placeholder(name="x")  #플레이스홀더는 이후 입력할 값으로 현재는 값까지는 초기화하지 않음

# Create hidden node y
y = tfg.Mul(a, x, name="y")  #곱 연산 클래스를 생성

# Create output node z
z = tfg.Add(y, b, name="z")  #합 연산 클래스를 생성

#nx.draw_networkx(g, with_labels=True)
#plt.show(block=True)

# 수행~~~~~~~~~~~~~~~~~~~~~~
session = tfs.Session()
output = session.run(z, {x: 1.0})
print(output)
output = session.run(z, {x: 2.0})
print(output)
Example #22
0
import tensorflux.graph as tfg
import tensorflux.session as tfs

apple_price = 100
apple_num = 2
tax = 1.1

g = tfg.Graph()

# Create variables
a = tfg.Variable(apple_price, name="a")
b = tfg.Variable(apple_num, name="b")
c = tfg.Variable(tax, name="c")

# Create Mul operation node
d = tfg.Mul(a, b, name="d")

# Create Mul operation node
e = tfg.Mul(d, c, name="e")

session = tfs.Session()
# forward
total_apple_price = session.run(d, verbose=False)
print("total_apple_price: {:f}".format(float(total_apple_price)))
final_price = session.run(e, verbose=False)
print("final_price: {:f}".format(float(final_price)))

print()

#backward
d_in = 1