def __init__(self, y, a): """ The mean squared error cost function. Should be used as the last node for a network. """ # Call the base class' constructor. Node.__init__(self, [y, a])
def test_node_interface(self): """ Testa se não tem implementação de forward na classe Node """ node = Node() with self.assertRaises(NotImplementedError): node.forward()
def build(regextree: Node) -> NFA: if not regextree: return AutomatonBuilder.emptyWord() elif isinstance(regextree, Concat): nfa1 = build(regextree.getChildren()[0]) nfa2 = build(regextree.getChildren()[1]) return concat(nfa1, nfa2) elif isinstance(regextree, Union): nfa1 = build(regextree.getChildren()[0]) nfa2 = build(regextree.getChildren()[1]) return union(nfa1, nfa2) elif isinstance(regextree, Star): nfa = build(regextree.getChildren()[0]) return star(nfa) elif isinstance(regextree, Literal): return literal(regextree) elif isinstance(regextree, Group): return build(regextree.getChildren()[0]) else : raise Exception("Cannot build NFA for : :" + str(regextree))
def discover_fuel_nodes(fuel_url, creds, cluster_name): username, tenant_name, password = parse_creds(creds) creds = { "username": username, "tenant_name": tenant_name, "password": password } conn = fuel_rest_api.KeystoneAuth(fuel_url, creds, headers=None) cluster_id = fuel_rest_api.get_cluster_id(conn, cluster_name) cluster = fuel_rest_api.reflect_cluster(conn, cluster_id) nodes = list(cluster.get_nodes()) ips = [node.get_ip('admin') for node in nodes] roles = [node["roles"] for node in nodes] host = urlparse(fuel_url).hostname nodes, to_clean = run_agent(ips, roles, host, tmp_file) nodes = [Node(node[0], node[1]) for node in nodes] openrc_dict = cluster.get_openrc() logger.debug("Found %s fuel nodes for env %r" % (len(nodes), cluster_name)) return nodes, to_clean, openrc_dict
def __init__(self, num_nodes, arrival_rate, duration=1000): self.stability_criteria = 0.05 self.duration = duration self.packet_length = 1500 self.transmission_time = self.packet_length / 1e6 # packet length / channel speed [secs] self.prop_time = 10 / ((2 / 3) * 3e8) # distance / prop_speed [secs] self.nodes = [ Node(i, duration, arrival_rate) for i in range(0, num_nodes) ]
def powerTraceLineProcess(line): #discard first five minutes if int(line.split(':', 1)[0]) < 5: return None # add dictionary from node id to set of powerUsage values and plot them using # differences of successive values or ~simply compute average~ tokens = line.split(" ") if "P" in tokens and "#P" not in tokens[0]: nodeinfo = tokens[0].split("\t") time = nodeinfo[0] id = int(nodeinfo[1].split(":")[1]) Tx = int(tokens[11]) Rx = int(tokens[12]) CPU = int(tokens[13]) LPM = int(tokens[14]) if id not in powerDictionary: powerDictionary[id] = Node(id, Tx, Rx, CPU, LPM) else: powerDictionary[id].addPowerStatistic(Tx, Rx, CPU, LPM) powerDictionary[id].powerTick(time, Node.computePowerUsage(Tx, Rx, CPU, LPM))
def __init__(self): Node.__init__(self)
def __init__(self, x, y): Node.__init__(self, [x, y])
def __init__(self, inputs, weights, bias): Node.__init__(self, [inputs, weights, bias])
def __init__(self, node): Node.__init__(self, [node])