# Path: src/net.py
# class Net(object):
#     # Sugar syntax
#     def __init__(self):
#         self._server = ParameterServer()
#         self._finalized = False
#         self._dagraph = DAG()
#         coated = sugar.__dict__
#         for name, fun in coated.items():
#             if callable(fun): setattr(Net, name, fun)
#  
#     # To be sugar coated
#     def _x(self, name, *args):
#         assert not self._finalized, \
#         'Graph is finalized by setting an optimizer'
#         return self._dagraph.register_for_slot(
#             name, self._server, *args)
# 
#     def optimize(self, ptr, optimizer,
#                  *args, **kwargs):
#         self._finalized = True
#         self._dagraph.set_closure(ptr)
#         self._server.set_optimizer(
#             optimizer, *args, **kwargs)
# 
#     def forward(self, fetches, feed):
#         return self._dagraph.forward(fetches, feed)
# 
#     def train(self, fetches, feed):
#         val = self._dagraph.forward_to_leaf(fetches, feed)
#         self._dagraph.backward()
#         self._server.apply_optimizer()
#         return val
# 
#     def save_checkpoint(self, file_name):
#         self._server.save(file_name)
# 
#     def load_checkpoint(self, file_name, *args, **kwargs):
#         self._server.load(file_name, *args, **kwargs)
# 
# Path: src/utils/misc.py
# def accuracy(predict, truth):
# def read_mnist():
# def xavier(shape):
# def extract(name, dfault, **kwargs):
# def nxshape(volume, shape):
# def parse_for(class_type, *args):


from src.net import Net
from src.utils.misc import uniform, xavier
import numpy as np

def _fc_with_wb(net, x, w, b, activate):
    linear = net.plus_b(net.matmul(x, w), b)
    return activate(linear)

def _fc(net, x, inp_dim, out_dim, activate):

# Path: src/net.py
# class Net(object):
#     # Sugar syntax
#     def __init__(self):
#         self._server = ParameterServer()
#         self._finalized = False
#         self._dagraph = DAG()
#         coated = sugar.__dict__
#         for name, fun in coated.items():
#             if callable(fun): setattr(Net, name, fun)
#  
#     # To be sugar coated
#     def _x(self, name, *args):
#         assert not self._finalized, \
#         'Graph is finalized by setting an optimizer'
#         return self._dagraph.register_for_slot(
#             name, self._server, *args)
# 
#     def optimize(self, ptr, optimizer,
#                  *args, **kwargs):
#         self._finalized = True
#         self._dagraph.set_closure(ptr)
#         self._server.set_optimizer(
#             optimizer, *args, **kwargs)
# 
#     def forward(self, fetches, feed):
#         return self._dagraph.forward(fetches, feed)
# 
#     def train(self, fetches, feed):
#         val = self._dagraph.forward_to_leaf(fetches, feed)
#         self._dagraph.backward()
#         self._server.apply_optimizer()
#         return val
# 
#     def save_checkpoint(self, file_name):
#         self._server.save(file_name)
# 
#     def load_checkpoint(self, file_name, *args, **kwargs):
#         self._server.load(file_name, *args, **kwargs)
# 
# Path: src/utils/misc.py
# def accuracy(predict, truth):
# def read_mnist():
# def xavier(shape):
# def extract(name, dfault, **kwargs):
# def nxshape(volume, shape):
# def parse_for(class_type, *args):


# Path: src/agents/qfunction.py
from src.net import Net
from src.utils.misc import uniform, xavier
import numpy as np


def _fc_with_wb(net, x, w, b, activate):
    linear = net.plus_b(net.matmul(x, w), b)
    return activate(linear)

def _fc(net, x, inp_dim, out_dim, activate):

    w = net.variable(xavier((inp_dim, out_dim)))