当前位置: 首页>>代码示例>>Python>>正文


Python network.network函数代码示例

本文整理汇总了Python中network.network函数的典型用法代码示例。如果您正苦于以下问题:Python network函数的具体用法?Python network怎么用?Python network使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了network函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():
	# Load data files
	nRows_iris = 150
	nColumns_iris = 5
	num_epoch_iris = 1
	learning_rate_iris = .5
	nRows_diabetes = 768
	nColumns_diabetes = 9
	num_epoch_diabetes = 1
	learning_rate_diabetes = .5
	iris = lf.load_file("iris.csv", nRows_iris, nColumns_iris)
	diabetes = lf.load_file("diabetes.data", nRows_diabetes, nColumns_diabetes)

	# Collect target data before it is normalized
	iris_targets = []
	diabetes_targets = []

	for row in range(nRows_iris):
		iris_targets.append(iris[row][nColumns_iris - 1])

	for row in range(nRows_diabetes):
		diabetes_targets.append(diabetes[row][nColumns_diabetes - 1])

	# Normalize data files
	iris = preprocessing.normalize(iris)
	diabetes = preprocessing.normalize(diabetes)

	# Run Iris
	iris_num_layers_array = [1, 3] # Length is num_layers, each element is num_nodes	
	for i in range(num_epoch_iris):
		np.random.shuffle(iris)
		iris_net = net.network(iris_num_layers_array, nRows_iris, nColumns_iris, iris, "Iris", learning_rate_iris)
		iris_net.run_network()
		iris_net.generate_guesses()
		iris_net.update_weights()
		iris_net.print_accuracy(iris_targets)	
		if learning_rate_iris > .1:
			learning_rate_iris -= .001
		


	# Run Diabetes
	diabetes_num_layers_array = [1, 2]
	for i in range(num_epoch_diabetes):
		np.random.shuffle(diabetes)
		diabetes_net = net.network(diabetes_num_layers_array, nRows_diabetes, nColumns_diabetes, diabetes, "Diabetes", learning_rate_diabetes)
		diabetes_net.run_network()
		diabetes_net.generate_guesses()
		diabetes_net.update_weights()
		diabetes_net.print_accuracy(diabetes_targets)

		if learning_rate_diabetes > .1:
			learning_rate_diabetes -= .001
开发者ID:diabloazul14,项目名称:Jarvis,代码行数:53,代码来源:tony.py

示例2: __init__

 def __init__(self,ip,mac):
     self.myip=ip
     self.mymac=mac
     self.tools=tools()
     self.mem=memory()
     self.network=network()
     self.replyTimeout=20
开发者ID:SDNMap,项目名称:sdnmap,代码行数:7,代码来源:forensic_protocol_prober.py

示例3: main

def main():
    #data_input = get_pix_img_in_list("test.png")
    #data_input = get_pix_img_in_list("a.bmp")
    #data_input = get_pix_img_in_list("a.png")

#test and

    data_input = [[0, 0], [0, 1], [1, 0], [1, 1]]
    data_output = [0, 0, 0, 1]

    net = network.network(2, 0.1)# 0,001 > x > 0,01
    i = 0
    while i < 2800:
        #net.train(data_input, ord(data_output))

        net.train(data_input[0], data_output[0])
        net.train(data_input[1], data_output[1])
        net.train(data_input[2], data_output[2])
        net.train(data_input[3], data_output[3])
        i = i + 1

    print("##### test ##### ")
    net.test(data_input[0])
    net.test(data_input[1])
    net.test(data_input[2])
    net.test(data_input[3])
开发者ID:remi-hernandez,项目名称:OCR,代码行数:26,代码来源:main.py

示例4: __init__

 def __init__(self,ip,mac):
     self.myip=ip
     self.mymac=mac
     self.tools=tools()
     self.mem=memory()
     self.ruleconstructor=ruleconstructor()
     self.recv_target=None
     self.sent_target=None
     self.network=network()
开发者ID:SDNMap,项目名称:sdnmap,代码行数:9,代码来源:forensic_port_prober.py

示例5: network_query

 def network_query(self, query_msg, source):
     with self.lock:
         net = network(query_msg.address, query_msg.netmask)
         if net.key() in self.networks:
             net = self.networks[net.key()]
             if net.root:
                 switch = net.switch_name()
                 msg = message.NetworkReplyMessage(query_msg.address, query_msg.netmask, switch)
                 self.topology.send_message(msg, source)
开发者ID:rpasea,项目名称:simulation_platform,代码行数:9,代码来源:simulator_node.py

示例6: __init__

	def __init__(self,url):
		self.connection=docker.Client(base_url=url)
		if os.path.isdir("/etc/config"):
			pass
		else:
			utils.execute("mkdir /etc/config")
		self.path="/etc/config/"
		self.netpath="/etc/network/"
		self.net=network.network()
开发者ID:zwqzhangweiqiang,项目名称:dnet,代码行数:9,代码来源:container.py

示例7: create_network

 def create_network(self, address, netmask, name_suffix=""):
     print "Creating network ", address, ":", netmask
     net = network(address, netmask, name_suffix, self)
     if net.key() not in self.networks:
         net.start()
         net.root = True
         self.networks[net.key()] = net
         msg = message.NetworkQueryMessage(address, netmask)
         self.topology.broadcast(msg)
开发者ID:rpasea,项目名称:simulation_platform,代码行数:9,代码来源:simulator_node.py

示例8: network_reply

 def network_reply(self, reply_msg, source):
     addr = self.topology.address_of_id(source)
     if addr is not None:
         with self.lock:
             net = network(reply_msg.address, reply_msg.netmask)
             if net.key() in self.networks:
                 net = self.networks[net.key()]
                 net.root = False
                 net.root_id = source
                 net.reattach_containers()
                 net.wire(addr, reply_msg.switch)
开发者ID:rpasea,项目名称:simulation_platform,代码行数:11,代码来源:simulator_node.py

示例9: __init__

	def __init__( self ):
		self.lib_version		= '1.0.0'
		self.api_key			= None
		self.api_private		= None
		self.base_url			= 'https://rest.quiubas.com'
		self.version			= '1.0'

		self.network = network( self )

		self.balance = balance( self )
		self.callback = callback( self )
		self.keywords = keywords( self )
		self.sms = sms( self )
开发者ID:quiubas,项目名称:quiubas-python,代码行数:13,代码来源:quiubas.py

示例10: main

def main():
    '''
    Main method:
        Here I read the input, and for
    '''
    net = network()
    n = int(input())
    inputX = []
    inputY = []
    outputs = []
    totalError = 0

    for i in range(n):
        inp = [int(x) for x in raw_input().split(' ')]
        inputX.append(inp[0])
        inputY.append(inp[1])
        outputs.append(inp[2])

    cont = 0
    # Each loop is an epoch.
    # While there isn't a set of weights on the neural network with error less than 0.4 the loop doesnt break.
    for currentOrder in permutations(range(n)):
        outs = []
        for i in currentOrder:
            outs.append(net.getOutput(inputX[i], inputY[i])) # Calculating the output
            net.updateWeights(inputX[i], inputY[i], outputs[i]) # Updating the weights of the Neural network
		
        totalError = 0
        goingToBreak = True
        for i in currentOrder:
            totalError += (outputs[i]-outs[i])**2
            if abs(outputs[i]-outs[i]) > 0.4:
                goingToBreak = False
        if goingToBreak:
            break
    
        if cont % 10 == 0:
            print('Epoch ' + str(cont))
            print('Squared Error: ' + str(totalError) + '\n')
        cont += 1

    delta = 0
    for i in range(n):
        o = net.getOutput(inputX[i], inputY[i])
        delta += abs(outputs[i]-o)
        print('Exemplar: ' + str(inputX[i]) + ' ' + str(inputY[i]) + ' ' + str(outputs[i]) + '   Neural Network Output: ' + str(o))
    print('\ndelta: ' + str(delta/8))
开发者ID:thiagovas,项目名称:Artificial-Neural-Network,代码行数:47,代码来源:main.py

示例11: move_container_to_network

    def move_container_to_network(self, container, address, netmask, network_name_suffix = ''):
        print 'Moving container ', container, ' to network: ', address, ':', netmask
        if container not in self.containers:
            raise InvalidOperation("Don't have container + " + container + ".")
 
        with self.lock:
            net = network(address, netmask)
            if net.key() not in self.networks:
                self.create_network(address, netmask, network_name_suffix)
            net = self.networks[net.key()]
                
            if self.containers[container].network_key in self.networks:
                self.networks[container.network_key].detach_container(container)
                if not self.networks[container.network_key].used:
                    self.networks[container.network_key].stop()
                    del self.networks[container.network_key]
            net.attach_container(self.containers[container])
开发者ID:rpasea,项目名称:simulation_platform,代码行数:17,代码来源:simulator_node.py

示例12: __init__

    def __init__(self, parent):
        self.parent = parent
        self.device = parent.device
        self.data_layer = parent.data_layer
        self.apps = parent.apps
        self.marionette = parent.marionette
        self.actions = Actions(self.marionette)

        # Globals used for reporting ...
        self.errNum = 0
        self.start_time = time.time()

        # Get run details from the OS.
        self.general = general(self)
        self.test_num = parent.__module__[5:]

        self.app = app(self)
        self.date_and_time = date_and_time(self)
        self.debug = debug(self)
        self.element = element(self)
        self.home = home(self)
        self.iframe = iframe(self)
        self.messages = Messages(self)
        self.network = network(self)
        self.reporting = reporting(self)
        self.statusbar = statusbar(self)
        self.test = test(self)
        self.visual_tests = visualtests(self)

        self.marionette.set_search_timeout(10000)
        self.marionette.set_script_timeout(10000)

        elapsed = time.time() - self.start_time
        elapsed = round(elapsed, 0)
        elapsed = str(datetime.timedelta(seconds=elapsed))
        self.reporting.debug("Initializing 'UTILS' took {} seconds.".format(elapsed))
        current_lang = parent.data_layer.get_setting("language.current").split('-')[0]
        self.reporting.info("Current Toolkit language: [{}]".format(current_lang))
        try:
            btn = self.marionette.find_element('id', 'charge-warning-ok')
            btn.tap()
        except:
            pass
        parent.data_layer.set_setting('screen.automatic-brightness', True)
开发者ID:owdqa,项目名称:OWD_TEST_TOOLKIT,代码行数:44,代码来源:utils.py

示例13: test_tfnet

def test_tfnet(task, projdir, modelname, sessionname, dataset, taskargs, patchflag=False, patchsize=100):

    # FOLDER VARIABLES
    sessiondir = projdir + "nets/" + modelname + "_" + sessionname + "/"
    resultsdir = projdir + "testresults/" + modelname + "_" + sessionname + "/"
    datadir = projdir + "data/" + dataset
    test_dir = datadir + "/testing"

    if not os.path.exists(resultsdir):
        os.mkdir(resultsdir)

    # NETWORK INIT
    x = tf.placeholder("float", shape=[None, None, None, 3])
    # xsize = tf.placeholder(tf.int32, shape=[2])
    y_conv = network(x, modelname, taskargs)

    taskobj = get_task(task)

    sess = tf.Session()

    saver = tf.train.Saver()
    if os.path.isfile(sessiondir + "checkpoint"):
        saver.restore(sess, tf.train.latest_checkpoint(sessiondir))
    else:
        print "Model not pretrained"

    # DATA INIT
    det_data, filenames = taskobj.read_testing_sets(test_dir)
    testdata = preprocess(det_data.testdata)

    # TESTING
    outs = []
    for j in range(testdata.shape[0]):
        print j
        res = sess.run([y_conv], feed_dict={x: testdata[j : j + 1]})
        outs.append(res[0])
    taskobj.validate(outs, det_data.testdata, None, resultsdir, taskargs)
开发者ID:BigDenni,项目名称:CellClassification,代码行数:37,代码来源:tfnet.py

示例14: network

from consts import ZMQ_SERVER_NETWORK, ZMQ_PUBSUB_KV17
from network import network
from helpers import serialize
import zmq
import sys

# Initialize the cached network
sys.stderr.write('Caching networkgraph...')
net = network()
sys.stderr.write('Done!\n')

# Initialize a zeromq context
context = zmq.Context()

# Set up a channel to receive network requests
sys.stderr.write('Setting up a ZeroMQ REP: %s\n' % (ZMQ_SERVER_NETWORK))
client = context.socket(zmq.REP)
client.bind(ZMQ_SERVER_NETWORK)

# Set up a channel to receive KV17 requests
sys.stderr.write('Setting up a ZeroMQ SUB: %s\n' % (ZMQ_PUBSUB_KV17))
subscribe_kv17 = context.socket(zmq.SUB)
subscribe_kv17.connect(ZMQ_PUBSUB_KV17)
subscribe_kv17.setsockopt(zmq.SUBSCRIBE, '')

# Set up a poller
poller = zmq.Poller()
poller.register(client, zmq.POLLIN)
poller.register(subscribe_kv17, zmq.POLLIN)

sys.stderr.write('Ready.\n')
开发者ID:StichtingOpenGeo-Museum,项目名称:transitpubsub,代码行数:31,代码来源:zmq_network.py

示例15: file

numEpisodes = 100000
batch_size = 64

#if load parameter is passed load a network from a file
if args.load:
	print "loading model..."
	f = file(args.load, 'rb')
	network = cPickle.load(f)
	if(network.batch_size):
		batch_size = network.batch_size
	f.close()
else:
	print "building model..."
	#use batchsize none now so that we can easily use same network for picking single moves and evaluating batches
	network = network(batch_size=None)
	print "network size: "+str(network.mem_size.eval())

evaluate_model_single = theano.function(
	[input_state],
	network.output[0],
	givens={
        network.input: input_state.dimshuffle('x', 0, 1, 2),
	}
)

evaluate_model_batch = theano.function(
	[state_batch],
	network.output,
	givens={
        network.input: state_batch,
开发者ID:kenjyoung,项目名称:Neurohex,代码行数:30,代码来源:mohex_q_learn.py


注:本文中的network.network函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。