本文整理汇总了Python中neuralnet.NeuralNet.load_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python NeuralNet.load_from_file方法的具体用法?Python NeuralNet.load_from_file怎么用?Python NeuralNet.load_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neuralnet.NeuralNet
的用法示例。
在下文中一共展示了NeuralNet.load_from_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StageRecognizer
# 需要导入模块: from neuralnet import NeuralNet [as 别名]
# 或者: from neuralnet.NeuralNet import load_from_file [as 别名]
class StageRecognizer():
def __init__(self, trained_net_path):
self.net = NeuralNet()
self.net.load_from_file(trained_net_path)
def recognize_image(self, img):
net_return = self.net.apply_over_data(extract_counter_feat(img))
stage_number = int(round(net_return))
stage = ''
precision = 'strong'
if stage_number == 1:
stage = 'red'
if abs(stage_number - 1) > .15:
precision = 'weak'
elif stage_number == 2:
stage = 'yellow'
if abs(stage_number - 1) > .15:
precision = 'weak'
elif stage_number == 3:
stage = 'green'
if abs(stage_number - 1) > .15:
precision = 'weak'
return stage, precision
示例2: findBin
# 需要导入模块: from neuralnet import NeuralNet [as 别名]
# 或者: from neuralnet.NeuralNet import load_from_file [as 别名]
def findBin(frame):
image=cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
pil_im = Image.fromarray(image)
#~ img1 = pil_im.resize((basewidth, height), Image.ANTIALIAS)
pil_im.thumbnail((256, 256), Image.ANTIALIAS)
img2 = pil_im.convert('1')
#~ pixels = img2.load()
pixels1 = np.asarray(img2.getdata(),dtype=np.bool)
outstr = "outimg" +".bmp"
img2.save(outstr)
array01 = []
count = 0
Tot = 0
for item in pixels1:
Tot += 1
if not item:
array01.append(1)
count += 1
else:
array01.append(0)
testitem = []
testitem.append(Instance(array01, [0]))
# load a stored network configuration
network = NeuralNet.load_from_file( "plastic122.pkl" )
arr = network.print_test(testitem)
print('Value returned by neural network plastic: ' + str(arr[0]))
network2 = NeuralNet.load_from_file( "metal122.pkl" )
arr2 = network2.print_test(testitem)
print('Value returned by neural network metal: ' + str(arr2[0]))
network3 = NeuralNet.load_from_file( "paper122.pkl" )
arr3 = network3.print_test(testitem)
print('Value returned by neural network paper: ' + str(arr3[0]))
pl = arr[0]
me = arr2[0]
pa = arr3[0]
if((pl > pa and pl > me) or pl > 0.5 or (pa < 0.42 and me < 0.09) ):
return 1 #plastic
elif((me > pa and me > pl) or me > 0.13):
return 3 #metal
else:
return 2 #paper
示例3: NeuralNet
# 需要导入模块: from neuralnet import NeuralNet [as 别名]
# 或者: from neuralnet.NeuralNet import load_from_file [as 别名]
#~ # The last pair in you list describes the number of output signals
#~
#~ # Optional settings
#~ "weights_low" : -0.1, # Lower bound on initial weight range
#~ "weights_high" : 0.1, # Upper bound on initial weight range
#~ "save_trained_network" : True, # Whether to write the trained weights to disk
#~
#~ "input_layer_dropout" : 0.0, # dropout fraction of the input layer
#~ "hidden_layer_dropout" : 0.0, # dropout fraction in all hidden layers
#~ }
# initialize the neural network
#~ network = NeuralNet( settings )
# load a stored network configuration
network = NeuralNet.load_from_file( "network5.pkl" )
# Train the network using backpropagation
#~ backpropagation(
#~ network,
#~ training_one, # specify the training set
#~ ERROR_LIMIT = 0.001, # define an acceptable error limit
#~ #max_iterations = 100, # continues until the error limit is reach if this argument is skipped
#~
#~ # optional parameters
#~ learning_rate = 0.03, # learning rate
#~ momentum_factor = 0.4, # momentum
#~ )
#~
#~ # Train the network using SciPy
#~ scipyoptimize(
示例4: load_network
# 需要导入模块: from neuralnet import NeuralNet [as 别名]
# 或者: from neuralnet.NeuralNet import load_from_file [as 别名]
def load_network():
if os.path.isfile("networks/XOR_Operator/XOR_Operator.obj"):
global network
network = NeuralNet.load_from_file("networks/XOR_Operator/XOR_Operator.obj")
else:
raise ValueError("networks/XOR_Operator/XOR_Operator.obj")