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)
import tensorflux2.graph as tfg import tensorflux2.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
from tensorflux2 import graph as tfg from tensorflux2 import session as tfs 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.Mul(w, x, name="y") # Create output node z z = tfg.Add(y, b, name="z") session = tfs.Session() output = session.run(z, {x: 1.0}) print(output) output = session.run(z, {x: 2.0}) print(output) output = session.run(z, {x: 3.0}) print(output)
def initialize_param(self): self.param = tfg.Variable(np.random.random(size=self.shape), name=self.name)
def initialize_param(self): self.param = tfg.Variable(np.random.normal(loc=0.0, scale=0.1, size=self.shape), name=self.name)
def initialize_param(self): self.param = tfg.Variable(np.ones(shape=self.shape) * 0.1, name=self.name)
def initialize_param(self): self.param = tfg.Variable(np.random.randn(self.shape[0], self.shape[1]), name=self.name)
def initialize_param(self): self.param = tfg.Variable(np.zeros(shape=self.shape), name=self.name)
def initialize_param(self): self.param = tfg.Variable(self.value, name=self.name)