Exemple #1
0
    def __init__(self,
                 num_in_ch,
                 num_out_ch,
                 kernel,
                 stride=1,
                 pad=0,
                 use_bias=True):
        """
        引数
            num_in_ch   入力チャンネル数
            num_out_ch  出力チャンネル数
            kernel      カーネルサイズ
            strid       ストライドサイズ
            pad         ゼロパディング数
            use_bias    biasを使うかどうか
        """
        super(Convolution2D, self).__init__()

        self.kernel = kernel
        self.stride = stride
        self.pad = pad
        self.use_bias = use_bias

        self.parameters = {
            "W":
            node.Node(np.random.randn(num_out_ch, num_in_ch, kernel,
                                      kernel).astype(np.float32),
                      name="W")
        }
        if use_bias:
            self.parameters["b"] = node.Node(np.zeros(num_out_ch,
                                                      dtype=np.float32),
                                             name="b")
Exemple #2
0
def stack(mini_batch):
    inputs, targets = [], []
    for input, target in mini_batch:
        inputs.append(input)
        targets.append(target)

    return (node.Node(np.array(inputs),
                      off=True), node.Node(np.array(targets), off=True))
Exemple #3
0
    def __init__(self, num_in_units, num_h_units):
        super(Linear, self).__init__()

        self.parameters = {
            "W":
            node.Node(np.random.randn(num_in_units,
                                      num_h_units).astype(np.float32),
                      name="W"),
            "b":
            node.Node(np.zeros(num_h_units, dtype=np.float32), name="b")
        }
Exemple #4
0
 def _construct(self):
     """
     构建系统
     :return:
     """
     """1)创建通道"""
     for _ch in self.structure["channel"]:
         _c = channel.Channel(_ch)
         self.R.add_channel(_c)
     """2)创建节点"""
     for _nd in self.structure["node"]:
         _n = node.Node(_nd)
         _n.add_function(self.structure["node"][_nd]["function"])
         self.R.add_node(_n)
         """创建输入通道"""
         if "input" in self.structure["node"][_nd]:
             for _ch in self.structure["node"][_nd]["input"]:
                 _n.add_in_channel(_ch)
         """创建输出通道"""
         if "output" in self.structure["node"][_nd]:
             for _ch in self.structure["node"][_nd]["output"]:
                 _n.add_out_channel(_ch)
                 if "init" in self.structure["node"][_nd]:
                     _events = self.structure["node"][_nd]["init"]()
                     _q = self.R.get_channel(_ch)
                     for _e in _events:
                         _q.in_q(_e)
         """创建同步器"""
         if "synchronizer" in self.structure["node"][_nd]:
             if self.structure["node"][_nd]["synchronizer"]:
                 _sync = synchronizer.Synchronizer()
                 _n.add_synchronizer(_sync)
Exemple #5
0
    def __init__(self, num_in_units, alpha=0.9, eps=1e-5):
        """
        引数
            num_in_units   ユニット数(入力が4Dの時はチャンネル数)
            alpha          移動平均の更新率をコントロール
            eps            ゼロ除算を防ぐ
        """
        super(BatchNormalization, self).__init__()

        self.parameters = {
            "W":
            node.Node(np.random.randn(num_in_units).astype(np.float32),
                      name="W"),
            "b":
            node.Node(np.zeros(num_in_units, dtype=np.float32), name="b")
        }

        self.alpha = alpha
        self.eps = eps

        self.running_mu = node.Node(np.zeros(num_in_units, dtype=np.float32))
        self.running_var = node.Node(np.ones(num_in_units, dtype=np.float32))
Exemple #6
0
def create_node():
    # Instantiate node
    pin = node.Node()
    # Set node params
    pin.node_name = 'Current monitoring dashboard'
    pin.node_description = 'Current trend monitoring system'
    pin.node_number = 'N1_1507'

    pin.host_ip = '127.0.0.1'
    # pin.host_ip = '192.168.3.250'
    pin.host_port = '502'
    # Load register map
    # map = pin.load_register_map()
    # Connect with slave
    pin.connect()
    # Create and connect to db
    engine = create_engine('sqlite:///database/current_data.db', echo=False)
    # Initiate the basic page

    return pin, map, engine
    def set_up_nodes(self):
        config_list = self.config_list
        if not config_list:
            config_name = utility.camel_to_snake(self.__class__.__name__)
            try:
                with open('./config_jsons/' + config_name +
                          '.json') as config_file:
                    self.config_list = json.load(config_file)
            except FileNotFoundError:
                raise FileNotFoundError(
                    'need a file named ' + config_name + '.json,' +
                    'or you can pass in your node configurations parameter when ELATestMetaClass is Initialized'
                )

        project_path = os.environ.get('GOPATH') + '/'.join(config.ELA_PATH)
        print("source code path:", project_path)

        node_path = "%s/elastos_test_runner_%s" % (
            "./test", datetime.datetime.now().strftime("%Y%m%d_%H%M%S"))
        os.makedirs(node_path)
        print("Temp dir is:", node_path)
        nodes_list = []

        for index, item in enumerate(self.config_list):
            name = item['name']
            path = os.path.join(node_path, name + str(index))
            os.makedirs(path)
            shutil.copy(os.path.join(project_path, name), os.path.join(path))
            configuration = item['config']
            with open(path + '/config.json', 'w+') as f:
                f.write(json.dumps(configuration, indent=4))

            nodes_list.append(
                node.Node(i=index,
                          dirname=node_path,
                          configuration=configuration['Configuration']))

        return nodes_list
Exemple #8
0
    def __init__(self, num_in_ch, num_out_ch, kernel, stride=1, pad=0):
        """
        引数
            num_in_ch   上で示される関係性においてinputのチャンネル数
            num_out_ch  上で示される関係性においてoutputのチャンネル数
            kernel      カーネルサイズ
            stride      ストライドサイズ
            pad         ゼロパディング数
        """
        super(TransposedConvolution2D, self).__init__()

        self.num_in_ch = num_in_ch
        self.num_out_ch = num_out_ch
        self.kernel = kernel
        self.stride = stride
        self.pad = pad

        self.parameters = {
            "W":
            node.Node(np.random.randn(num_in_ch, num_out_ch, kernel,
                                      kernel).astype(np.float32),
                      name="W")
        }
Exemple #9
0
    print(str10)
    print(perc_list[9])
    print(str11)
    print(perc_list[10])
    print(str12)
    print(perc_list[11])
    print(str13)
    print(perc_list[12])
    print(str14)
    print(perc_list[13])
    print(str15)
    print(perc_list[14])


print("creating Node_a....")
Node_a = nd.Node("juan0o_")
print("creating Node_b....")
Node_b = nd.Node("alejandrouribe718")
print("\nThis is the name to Node_a__________________________\n")
print(Node_a.get_name())
print("\nThis is the follow list Node_a__________________________\n")
print(Node_a.get_follow_list())
print("\nThis is the following list Node_a__________________________\n")
print(Node_a.get_following_list())
print(Node_a.get_biography())
print("\nThis is the biography Node_a__________________________\n")
print("\nThis is numLikes to Node_a__________________________\n")
print(Node_a.get_likes())
print(
    "\nNow the realationship algorithm between Node_a and Node_b__________________________\n"
)