示例#1
0
try:
    sys.path.append(os.path.join(Path(os.getcwd()).parent, 'lib'))
    from layers import Multiply, Add
except ImportError:
    print('Library Module Can Not Found')

# data
apple = 100
applecount = 3
orange = 200
orangecount = 5
discount = 0.9

# layers
layer1 = Multiply()
layer2 = Multiply()
layer3 = Add()
layer4 = Multiply()

# forward
appleprice = layer1.forward(apple, applecount)
print(f'appleprice={appleprice}')

orangeprice = layer2.forward(orange, orangecount)
print(f'orangeprice={orangeprice}')

appleorangeprice = layer3.forward(appleprice, orangeprice)
print(f'appleorangeprice={appleorangeprice}')

totalprice = layer4.forward(appleorangeprice, discount)
示例#2
0
    sys.path.append(os.path.join(Path(os.getcwd()).parent, 'lib'))
    from layers import Multiply, Add
except ImportError:
    print('Library Module Can Not Found')

# data

apple = 100
applecount = 3
orange = 200
orangecount = 5
discount = 0.9

# layers

layer1_1 = Multiply()  # 병렬
layer1_2 = Multiply()
layer2 = Add()
layer3 = Multiply()

# forward
appleprice = 0
orangeprice = 0
appleorangeprice = 0
totalprice = 0

appleprice = layer1_1.forward(apple, applecount)
print(f'appleprice = {appleprice}')

orangeprice = layer1_2.forward(orange, orangecount)
print(f'orangeprice = {orangeprice}')
示例#3
0
import sys
import numpy as np
from pathlib import Path
try:
    sys.path.append(os.path.join(Path(os.getcwd()).parent, 'lib'))
    from layers import Multiply
except ImportError:
    print('Library Module Can Not Found')

# data
apple = 100
count = 5
discount = 0.9

# layers
layer1 = Multiply()
layer2 = Multiply()

# forward
appleprice = layer1.forward(apple, count)
print(f'apple prince : {appleprice}')

totalprice = layer2.forward(appleprice, discount)
print(f'totalprice : {totalprice}')

print('===========================================')

# backward propagation
dappleprice, ddiscount = layer2.backward(1)
print(f'dappleprice ={dappleprice}, ddiscount = {ddiscount}')
示例#4
0
from pathlib import Path
try:
    sys.path.append(os.path.join(Path(os.getcwd()).parent, 'lib'))
    from layers import Multiply, Add
except ImportError:
    print('Library Module Can Not Found')

# data
apple = 100
applecount = 3
orange = 200
orangecount = 5
discount = 0.9

# layers
layer1_apple = Multiply()
layer1_orange = Multiply()
layer2 = Add()
layer3 = Multiply()

# forward
appleprice = 0
orangeprice = 0
appleorangeprice = 0
totalprice = 0

appleprice = layer1_apple.forward(apple, applecount)
orangeprice = layer1_orange.forward(orange, orangecount)
print(f'appleprice = {appleprice}')
print(f'orangeprice = {orangeprice}')