• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python network.network函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: __init__

 def __init__(self):
     self.network=network()
     self.mem=memory()
开发者ID:SDNMap,项目名称:sdnmap,代码行数:3,代码来源:tools.py


示例17: create

from bottle import route, run,request
import images
import container
import network

ContainerApi=container.dockerapi(url="tcp://0.0.0.0:2375")
NetworkApi=network.network()
ImageApi=images.image(url="tcp://0.0.0.0:2375")

#create container
@route("/create",method="POST")

def create():
	body = request.json
	image=body.get("image")
	hostname=body.get("hostname")
	name=body.get("name")
	bridge=body.get("bridge")
	netname=body.get("netname")
	gateway=body.get("gateway")
	ContainerApi.create(image,hostname,name,bridge,netname,gateway)
	return {"name":name,
		"hostname":hostname,
		"image":image,
		"netname":netname,
		"bridge":bridge,
		"gateway":gateway
		}

#delete container
@route("/delete/<ContainName>",method="DELETE")
开发者ID:zwqzhangweiqiang,项目名称:dnet,代码行数:31,代码来源:dnetapi.py


示例18: neg_logistic

import math

import network

def neg_logistic(c, x):
	return c - 1/(1 + math.e**(-x))


net = network.network(input=[1, 3, 5], output=[1, 1, 1], hidden_count=2)

it = net.training_iterator(training_goal=0.03, history_size=10)
it.send(None)

#each row in training set consists of input list, output list, learning rate
training_data = [([1, 0.25, -0.5], [1, -1, 0], neg_logistic(2, n)) for n in range(100)]

try:
	for row in training_data:
		print it.send(row)
except StopIteration:
	print "training goal reached"

开发者ID:dbaumann,项目名称:csci568,代码行数:21,代码来源:main.py


示例19: network

#!/usr/bin/python2

from network import network

import pprint

truth_in 			= [[0,0],[0,1],[1,0],[1,1]]			#Input set
truth_out 			= [[0],[1],[1],[0]]					#Desired output set

net	                = network(2,1,3,1) 					#inputs, hidden_layers, hidden_neurons, outputs

net.initWeights()
#net.loadWeights("real_dice.txt")						#Load the weight values from a text file

net.debug 			= True								#Print debug info in the terminal
net.alpha			= 1									#Learning rate
net.adaptive_alpha	= True								#Adjust learning rate to increase if learning stagnates
net.alpha_roof		= 2 								#Learning rate max value

net.useGraph()											#Use the pygame visualisation
net.graph_freq      = 1									#Display the network after every epoch
#net.graph_image_seq	= True

#net.train(truth_in,truth_out,0,2000) 					#input_set, output_set, mode, epochs
cnt = net.train(truth_in,truth_out,1,0.01)				#input_set, output_set, mode, target_sse

#net.saveWeights("real_dice.txt")						#Save the weight values to a text file
开发者ID:SED9008,项目名称:Neural,代码行数:27,代码来源:main.py


示例20: file


parser = argparse.ArgumentParser()
parser.add_argument("source", type=str, help="Pickled network to steal params from.")
parser.add_argument("dest", type=str, help="File to place new network in.")
parser.add_argument(
    "--cpu", "-c", dest="cpu", action="store_const", const=True, default=False, help="Convert network to run on a CPU."
)
args = parser.parse_args()

print "loading model..."
f = file(args.source, "rb")
old_network = cPickle.load(f)
f.close()

params = old_network.params
if args.cpu:
    print "converting gpu parameters..."
    new_params = []
    for param in params:
        param = T._shared(param.get_value())
        new_params.append(param)
    params = new_params

new_network = network(batch_size=None, params=params)

print "saving model..."
f = file(args.dest, "wb")
cPickle.dump(new_network, f, protocol=cPickle.HIGHEST_PROTOCOL)
f.close()
开发者ID:kenjyoung,项目名称:Neurohex,代码行数:28,代码来源:fix_network.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python network.poll函数代码示例发布时间:2022-05-27
下一篇:
Python netutils.isValidIp函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap