本文整理汇总了Python中network.Network.load方法的典型用法代码示例。如果您正苦于以下问题:Python Network.load方法的具体用法?Python Network.load怎么用?Python Network.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network.Network
的用法示例。
在下文中一共展示了Network.load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Network
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import load [as 别名]
"""
Creator : Jayrese Heslop
Created on : 5/26/2016 (11:13 P.M.)
Last Editted: 6/16/2016 (01:38 P.M.)
"""
from layer import Layer
from neuron import Neuron
from network import Network
try:
# Attempt to load the network from a file
network = Network.load("test_binary.json")
except Exception as e:
# On failure, recreate the network from scratch
network = Network()
network.add_layer(10, 20, Network.ACTIVATION_SIGMOID) # Hidden Layer, 10 Neurons, 20 inputs
network.add_layer(2, 10, Network.ACTIVATION_SIGMOID) # Output Layer, 2 Neurons, 10 inputs
# Simulate black and white images
# 0 - Black
# 1 - White
zero = [0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0]
one = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0]
two = [0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1]
three = [1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1]
# Set some quick properties for the upcoming training session
示例2: main
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import load [as 别名]
def main():
"""
1. Input parser constructs the network.
2. Event handler is constructed, initial events loaded.
3. Begin simulation
"""
# Input parser
N = Network()
N.load('testfile.json')
N.draw()
# Event handler
# Begin simulation
pass
示例3: run_net
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import load [as 别名]
def run_net(net, lang, num_train, num_test, name=None):
name = name or lang + str(net.seed) + ('d' if net.distributed else 'l')
save_dir = 'nets/' + name
train, test, test_bounds = get_corpora(lang, num_train, num_test, net.distributed)
net.fit(*train)
print('saved', name)
net.save(save_dir)
test_result = net.test(*test)
test_errors = test_result['error_total']
test_outputs = test_result['out_activations']
exp_a_results = run_experiment(net, lang, 'A')
exp_a_errors = [result['error_total'] for result in exp_a_results]
net = Network.load(save_dir) # reset to before experiment A training
exp_b_results = run_experiment(net, lang, 'B')
exp_b_errors = [result['error_total'] for result in exp_b_results]
return {'lang': lang,
'name': name,
'distributed': net.distributed,
'test_errors': test_errors,
'test_outputs': test_outputs,
'exp_a_errors': exp_a_errors,
'exp_b_errors': exp_b_errors,
'test_bounds': test_bounds}
示例4: FFnetApp
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import load [as 别名]
class FFnetApp(HasTraits):
network = Instance(Network)
data = Instance(TrainingData)
training_data = Instance(TrainingData)
testing_data = Instance(TrainingData)
recall_data = Instance(TrainingData)
dumper = Instance(Dumper)
trainer = Instance(Trainer)
shared = Instance(Shared)
logs = Instance(Logger)
plots = Instance(MPLPlots, transient=True)
shell = PythonValue(Dict)
mode = Enum('train', 'test', 'recall')
algorithm = Enum('tnc') #, 'bfgs', 'cg')
running = DelegatesTo('trainer')
net = DelegatesTo('network')
data_status = DelegatesTo('data', prefix='status')
selected = DelegatesTo('plots')
def __init__(self, **traits):
super(FFnetApp, self).__init__(**traits)
self.network = Network(app = self)
self.training_data = TrainingData(app = self)
self.testing_data = TrainingData(app = self)
self.recall_data = TrainingData(app = self)
self.data = self.training_data # by default
self.dumper = Dumper(app=self)
self.trainer = TncTrainer(app = self) # default trainer
self.shared = Shared()
self.logs = Logger()
self.plots = MPLPlots()
self.logs.logger.info('Welcome! You are using ffnet-%s.' %ffnet_version)
self.shell = {'app':self}
def new(self):
net = self.network.create()
if net is not None:
self.mode = 'train'
self.data.normalize = True
self._new_net_setup()
def load(self):
net = self.network.load()
if net is not None:
self.mode = 'recall'
self._new_net_setup()
def save_as(self):
self.network.save_as()
def export(self):
self.network.export()
def dump(self):
self.dumper.configure_traits(kind='modal')
def settings(self):
if self.net:
self._pmode = self.mode
self.edit_traits(view='settings_view', kind='livemodal')
def train_start(self):
self.logs.logger.info('Training network: %s' %self.network.filename)
self.trainer.train()
def train_stop(self):
self.trainer.running = False
def reset(self):
if self.net:
self.net.randomweights()
self.logs.logger.info('Weights has been randomized!')
self.clear()
def about(self):
from about import about
about.open()
def donate(self):
import webbrowser
url = 'https://sourceforge.net/p/ffnet/donate'
webbrowser.open(url)
def cite(self):
from pyface.api import information
import os
try:
basedir = os.path.dirname(os.path.realpath(__file__)) + '/'
except NameError: #__file__ not defined if this is main script
basedir = ''
fname = basedir + 'data/cite.txt'
citations = open(fname, 'r').read()
msg = u'You are encouraged to cite in your papers one (or all) of the following:\n\n\n' + \
unicode(citations, 'utf-8').replace(u'\ufeff', '')
information(None, msg, title = "Citing ffnet/ffnetui")
def clear(self):
self.shared.populate()
self.plots.selected.replot()
#.........这里部分代码省略.........