本文整理匯總了Python中simplelearn.training.EpochLogger.subscribe_to方法的典型用法代碼示例。如果您正苦於以下問題:Python EpochLogger.subscribe_to方法的具體用法?Python EpochLogger.subscribe_to怎麽用?Python EpochLogger.subscribe_to使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類simplelearn.training.EpochLogger
的用法示例。
在下文中一共展示了EpochLogger.subscribe_to方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from simplelearn.training import EpochLogger [as 別名]
# 或者: from simplelearn.training.EpochLogger import subscribe_to [as 別名]
#.........這裏部分代碼省略.........
if output_prefix != "":
output_prefix = output_prefix + "_"
output_prefix = os.path.join(output_dir, output_prefix)
return "{}lr-{}_mom-{}_nesterov-{}_bs-{}".format(
output_prefix,
args.learning_rate,
args.initial_momentum,
args.nesterov,
args.batch_size)
"""
assert_equal(os.path.splitext(args.output_prefix)[1], "")
if os.path.isdir(args.output_prefix) and not args.output_prefix.endswith("/"):
args.output_prefix += "/"
output_dir, output_prefix = os.path.split(args.output_prefix)
if output_prefix != "":
output_prefix = output_prefix + "_"
output_prefix = os.path.join(output_dir, output_prefix)
epoch_logger = EpochLogger(output_prefix + "SGD_nesterov.h5")
# misclassification_node = Misclassification(output_node, label_node)
# mcr_logger = LogsToLists()
# training_stopper = StopsOnStagnation(max_epochs=10,
# min_proportional_decrease=0.0)
misclassification_node = Misclassification(output_node, label_lookup_node)
validation_loss_monitor = MeanOverEpoch(loss_node, callbacks=[])
epoch_logger.subscribe_to("validation mean loss", validation_loss_monitor)
validation_misclassification_monitor = MeanOverEpoch(
misclassification_node, callbacks=[print_mcr, StopsOnStagnation(max_epochs=20, min_proportional_decrease=0.0)]
)
epoch_logger.subscribe_to("validation misclassification", validation_misclassification_monitor)
# batch callback (monitor)
# training_loss_logger = LogsToLists()
training_loss_monitor = MeanOverEpoch(loss_node, callbacks=[print_loss])
epoch_logger.subscribe_to("training mean loss", training_loss_monitor)
training_misclassification_monitor = MeanOverEpoch(misclassification_node, callbacks=[])
epoch_logger.subscribe_to("training misclassification %", training_misclassification_monitor)
# epoch callbacks
# validation_loss_logger = LogsToLists()
def make_output_filename(args, best=False):
basename = make_output_basename(args)
return "{}{}.pkl".format(basename, "_best" if best else "")
# model = SerializableModel([input_indices_symbolic], [output_node])
# saves_best = SavesAtMinimum(model, make_output_filename(args, best=True))
validation_loss_monitor = MeanOverEpoch(loss_node, callbacks=[])
epoch_logger.subscribe_to("validation loss", validation_loss_monitor)
epoch_timer = EpochTimer2()
epoch_logger.subscribe_to("epoch duration", epoch_timer)
示例2: main
# 需要導入模塊: from simplelearn.training import EpochLogger [as 別名]
# 或者: from simplelearn.training.EpochLogger import subscribe_to [as 別名]
#.........這裏部分代碼省略.........
#
# Makes batch and epoch callbacks
#
def make_output_basename(args):
assert_equal(os.path.splitext(args.output_prefix)[1], "")
if os.path.isdir(args.output_prefix) and \
not args.output_prefix.endswith('/'):
args.output_prefix += '/'
output_dir, output_prefix = os.path.split(args.output_prefix)
if output_prefix != "":
output_prefix = output_prefix + "_"
output_prefix = os.path.join(output_dir, output_prefix)
return "{}lr-{}_mom-{}_nesterov-{}_bs-{}".format(
output_prefix,
args.learning_rate,
args.initial_momentum,
args.nesterov,
args.batch_size)
epoch_logger = EpochLogger(make_output_basename(args) + "_log.h5")
# misclassification_node = Misclassification(output_node, label_node)
# mcr_logger = LogsToLists()
# training_stopper = StopsOnStagnation(max_epochs=10,
# min_proportional_decrease=0.0)
misclassification_node = Misclassification(output_node, label_node)
validation_loss_monitor = MeanOverEpoch(loss_node, callbacks=[])
epoch_logger.subscribe_to('validation mean loss', validation_loss_monitor)
validation_misclassification_monitor = MeanOverEpoch(
misclassification_node,
callbacks=[print_mcr,
StopsOnStagnation(max_epochs=10,
min_proportional_decrease=0.0)])
epoch_logger.subscribe_to('validation misclassification',
validation_misclassification_monitor)
# batch callback (monitor)
# training_loss_logger = LogsToLists()
training_loss_monitor = MeanOverEpoch(loss_node, callbacks=[print_loss])
epoch_logger.subscribe_to('training mean loss', training_loss_monitor)
training_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[])
epoch_logger.subscribe_to('training misclassification %',
training_misclassification_monitor)
# epoch callbacks
# validation_loss_logger = LogsToLists()
def make_output_filename(args, best=False):
basename = make_output_basename(args)
return "{}{}.pkl".format(basename, '_best' if best else "")
model = SerializableModel([image_uint8_node], [output_node])
saves_best = SavesAtMinimum(model, make_output_filename(args, best=True))
validation_loss_monitor = MeanOverEpoch(
示例3: main
# 需要導入模塊: from simplelearn.training import EpochLogger [as 別名]
# 或者: from simplelearn.training.EpochLogger import subscribe_to [as 別名]
#.........這裏部分代碼省略.........
# Makes batch and epoch callbacks
#
def make_output_filename(args, best=False):
'''
Constructs a filename that reflects the command-line params.
'''
assert_equal(os.path.splitext(args.output_prefix)[1], "")
if os.path.isdir(args.output_prefix):
output_dir, output_prefix = args.output_prefix, ""
else:
output_dir, output_prefix = os.path.split(args.output_prefix)
assert_true(os.path.isdir(output_dir))
if output_prefix != "":
output_prefix = output_prefix + "_"
output_prefix = os.path.join(output_dir, output_prefix)
return ("%slr-%g_mom-%g_nesterov-%s_bs-%d%s.pkl" %
(output_prefix,
args.learning_rate,
args.initial_momentum,
args.nesterov,
args.batch_size,
"_best" if best else ""))
# Set up the loggers
epoch_logger = EpochLogger(make_output_filename(args) + "_log.h5")
misclassification_node = Misclassification(output_node, label_lookup_node)
validation_loss_monitor = MeanOverEpoch(loss_node, callbacks=[])
epoch_logger.subscribe_to('validation mean loss', validation_loss_monitor)
training_stopper = StopsOnStagnation(max_epochs=201,
min_proportional_decrease=0.0)
validation_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[print_misclassification_rate,
training_stopper])
epoch_logger.subscribe_to('validation misclassification',
validation_misclassification_monitor)
# batch callback (monitor)
#training_loss_logger = LogsToLists()
training_loss_monitor = MeanOverEpoch(loss_node,
callbacks=[print_loss])
epoch_logger.subscribe_to("training loss", training_loss_monitor)
training_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[])
epoch_logger.subscribe_to('training misclassification %',
training_misclassification_monitor)
epoch_timer = EpochTimer2()
epoch_logger.subscribe_to('epoch duration', epoch_timer)
# epoch_logger.subscribe_to('epoch time',
# epoch_timer)
#################
model = SerializableModel([input_indices_symbolic], [output_node])
saves_best = SavesAtMinimum(model, make_output_filename(args, best=True))
validation_loss_monitor = MeanOverEpoch(loss_node,
示例4: main
# 需要導入模塊: from simplelearn.training import EpochLogger [as 別名]
# 或者: from simplelearn.training.EpochLogger import subscribe_to [as 別名]
#.........這裏部分代碼省略.........
output_prefix = output_prefix + "_"
output_prefix = os.path.join(output_dir, output_prefix)
return ("%slr-%g_mom-%g_nesterov-%s_bs-%d%s.pkl" %
(output_prefix,
args.learning_rate,
args.initial_momentum,
args.nesterov,
args.batch_size,
"_best" if best else ""))
'''
# Set up the loggers
assert_equal(os.path.splitext(args.output_prefix)[1], "")
if os.path.isdir(args.output_prefix) and \
not args.output_prefix.endswith('/'):
args.output_prefix += '/'
output_dir, output_prefix = os.path.split(args.output_prefix)
if output_prefix != "":
output_prefix = output_prefix + "_"
output_prefix = os.path.join(output_dir, output_prefix)
epoch_logger = EpochLogger(output_prefix + "S2GD_plus.h5")
misclassification_node = Misclassification(output_node, label_lookup_node)
validation_loss_monitor = MeanOverEpoch(loss_node, callbacks=[])
epoch_logger.subscribe_to('validation mean loss', validation_loss_monitor)
training_stopper = StopsOnStagnation(max_epochs=20,
min_proportional_decrease=0.0)
validation_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[print_misclassification_rate,
training_stopper])
epoch_logger.subscribe_to('validation misclassification',
validation_misclassification_monitor)
# batch callback (monitor)
#training_loss_logger = LogsToLists()
training_loss_monitor = MeanOverEpoch(loss_node,
callbacks=[print_loss])
epoch_logger.subscribe_to("training loss", training_loss_monitor)
training_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[])
epoch_logger.subscribe_to('training misclassification %',
training_misclassification_monitor)
epoch_timer = EpochTimer2()
epoch_logger.subscribe_to('epoch duration', epoch_timer)
# epoch_logger.subscribe_to('epoch time',
# epoch_timer)
#################
#model = SerializableModel([input_indices_symbolic], [output_node])
#saves_best = SavesAtMinimum(model, make_output_filename(args, best=True))
validation_loss_monitor = MeanOverEpoch(loss_node,
示例5: main
# 需要導入模塊: from simplelearn.training import EpochLogger [as 別名]
# 或者: from simplelearn.training.EpochLogger import subscribe_to [as 別名]
#.........這裏部分代碼省略.........
# Makes batch and epoch callbacks
#
def make_output_filename(args, best=False):
'''
Constructs a filename that reflects the command-line params.
'''
assert_equal(os.path.splitext(args.output_prefix)[1], "")
if os.path.isdir(args.output_prefix):
output_dir, output_prefix = args.output_prefix, ""
else:
output_dir, output_prefix = os.path.split(args.output_prefix)
assert_true(os.path.isdir(output_dir))
if output_prefix != "":
output_prefix = output_prefix + "_"
output_prefix = os.path.join(output_dir, output_prefix)
return ("%slr-%g_mom-%g_nesterov-%s_bs-%d%s.pkl" %
(output_prefix,
args.learning_rate,
args.initial_momentum,
not args.no_nesterov,
args.batch_size,
"_best" if best else ""))
# Set up the loggers
epoch_logger = EpochLogger(make_output_filename(args) + "_log.h5")
misclassification_node = Misclassification(output_node, label_lookup_node)
validation_loss_monitor = MeanOverEpoch(loss_node, callbacks=[])
epoch_logger.subscribe_to('validation mean loss', validation_loss_monitor)
training_stopper = StopsOnStagnation(max_epochs=100,
min_proportional_decrease=0.0)
validation_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[print_misclassification_rate,
training_stopper])
epoch_logger.subscribe_to('validation misclassification',
validation_misclassification_monitor)
# batch callback (monitor)
#training_loss_logger = LogsToLists()
training_loss_monitor = MeanOverEpoch(loss_node,
callbacks=[print_loss])
epoch_logger.subscribe_to("training loss", training_loss_monitor)
training_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[])
epoch_logger.subscribe_to('training misclassification %',
training_misclassification_monitor)
epoch_timer = EpochTimer()
# epoch_logger.subscribe_to('epoch time',
# epoch_timer)
#################
model = SerializableModel([input_indices_symbolic], [output_node])
saves_best = SavesAtMinimum(model, make_output_filename(args, best=True))
validation_loss_monitor = MeanOverEpoch(loss_node,
callbacks=[saves_best])
示例6: main
# 需要導入模塊: from simplelearn.training import EpochLogger [as 別名]
# 或者: from simplelearn.training.EpochLogger import subscribe_to [as 別名]
#.........這裏部分代碼省略.........
#
# Makes batch and epoch callbacks
#
def make_output_basename(args):
assert_equal(os.path.splitext(args.output_prefix)[1], "")
if os.path.isdir(args.output_prefix) and \
not args.output_prefix.endswith('/'):
args.output_prefix += '/'
output_dir, output_prefix = os.path.split(args.output_prefix)
if output_prefix != "":
output_prefix = output_prefix + "_"
output_prefix = os.path.join(output_dir, output_prefix)
return "{}lr-{}_mom-{}_nesterov-{}_bs-{}".format(
output_prefix,
args.learning_rate,
args.initial_momentum,
args.nesterov,
args.batch_size)
epoch_logger = EpochLogger(make_output_basename(args) + "_log.h5")
# misclassification_node = Misclassification(output_node, label_node)
# mcr_logger = LogsToLists()
# training_stopper = StopsOnStagnation(max_epochs=10,
# min_proportional_decrease=0.0)
misclassification_node = Misclassification(output_node, label_node)
validation_loss_monitor = MeanOverEpoch(loss_node, callbacks=[])
epoch_logger.subscribe_to('validation mean loss', validation_loss_monitor)
validation_misclassification_monitor = MeanOverEpoch(
misclassification_node,
callbacks=[print_mcr,
StopsOnStagnation(max_epochs=10,
min_proportional_decrease=0.0)])
epoch_logger.subscribe_to('validation misclassification',
validation_misclassification_monitor)
# batch callback (monitor)
# training_loss_logger = LogsToLists()
training_loss_monitor = MeanOverEpoch(loss_node, callbacks=[print_loss])
epoch_logger.subscribe_to('training mean loss', training_loss_monitor)
training_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[])
epoch_logger.subscribe_to('training misclassification %',
training_misclassification_monitor)
# epoch callbacks
# validation_loss_logger = LogsToLists()
def make_output_filename(args, best=False):
basename = make_output_basename(args)
return "{}{}.pkl".format(basename, '_best' if best else "")
model = SerializableModel([image_uint8_node], [output_node])
saves_best = SavesAtMinimum(model, make_output_filename(args, best=True))
validation_loss_monitor = MeanOverEpoch(
示例7: main
# 需要導入模塊: from simplelearn.training import EpochLogger [as 別名]
# 或者: from simplelearn.training.EpochLogger import subscribe_to [as 別名]
#.........這裏部分代碼省略.........
# Makes batch and epoch callbacks
#
def make_output_filename(args, best=False):
'''
Constructs a filename that reflects the command-line params.
'''
assert_equal(os.path.splitext(args.output_prefix)[1], "")
if os.path.isdir(args.output_prefix):
output_dir, output_prefix = args.output_prefix, ""
else:
output_dir, output_prefix = os.path.split(args.output_prefix)
assert_true(os.path.isdir(output_dir))
if output_prefix != "":
output_prefix = output_prefix + "_"
output_prefix = os.path.join(output_dir, output_prefix)
return ("%slr-%g_mom-%g_nesterov-%s_bs-%d%s.pkl" %
(output_prefix,
args.learning_rate,
args.initial_momentum,
not args.no_nesterov,
args.batch_size,
"_best" if best else ""))
# Set up the loggers
epoch_logger = EpochLogger(make_output_filename(args) + "_log.h5")
misclassification_node = Misclassification(output_node, label_node)
validation_loss_monitor = MeanOverEpoch(loss_node, callbacks=[])
epoch_logger.subscribe_to('validation mean loss', validation_loss_monitor)
training_stopper = StopsOnStagnation(max_epochs=100,
min_proportional_decrease=0.0)
validation_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[print_misclassification_rate,
training_stopper])
epoch_logger.subscribe_to('validation misclassification',
validation_misclassification_monitor)
# batch callback (monitor)
#training_loss_logger = LogsToLists()
training_loss_monitor = MeanOverEpoch(loss_node,
callbacks=[print_loss])
epoch_logger.subscribe_to("training loss", training_loss_monitor)
training_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[])
epoch_logger.subscribe_to('training misclassification %',
training_misclassification_monitor)
epoch_timer = EpochTimer()
# epoch_logger.subscribe_to('epoch time',
# epoch_timer)
#################
model = SerializableModel([image_uint8_node], [output_node])
saves_best = SavesAtMinimum(model, make_output_filename(args, best=True))
validation_loss_monitor = MeanOverEpoch(loss_node,
callbacks=[saves_best])
示例8: main
# 需要導入模塊: from simplelearn.training import EpochLogger [as 別名]
# 或者: from simplelearn.training.EpochLogger import subscribe_to [as 別名]
#.........這裏部分代碼省略.........
#
# Makes batch and epoch callbacks
#
def make_output_basename(args):
assert_equal(os.path.splitext(args.output_prefix)[1], "")
if os.path.isdir(args.output_prefix) and \
not args.output_prefix.endswith('/'):
args.output_prefix += '/'
output_dir, output_prefix = os.path.split(args.output_prefix)
if output_prefix != "":
output_prefix = output_prefix + "_"
output_prefix = os.path.join(output_dir, output_prefix)
return "{}lr-{}_mom-{}_nesterov-{}_bs-{}".format(
output_prefix,
args.learning_rate,
args.initial_momentum,
args.nesterov,
args.batch_size)
epoch_logger = EpochLogger(make_output_basename(args) + "_log.h5")
# misclassification_node = Misclassification(output_node, label_node)
# mcr_logger = LogsToLists()
# training_stopper = StopsOnStagnation(max_epochs=10,
# min_proportional_decrease=0.0)
misclassification_node = Misclassification(output_node, label_lookup_node)
validation_loss_monitor = MeanOverEpoch(loss_node, callbacks=[])
epoch_logger.subscribe_to('validation mean loss', validation_loss_monitor)
validation_misclassification_monitor = MeanOverEpoch(
misclassification_node,
callbacks=[print_mcr,
StopsOnStagnation(max_epochs=100,
min_proportional_decrease=0.0)])
epoch_logger.subscribe_to('validation misclassification',
validation_misclassification_monitor)
# batch callback (monitor)
# training_loss_logger = LogsToLists()
training_loss_monitor = MeanOverEpoch(loss_node, callbacks=[print_loss])
epoch_logger.subscribe_to('training mean loss', training_loss_monitor)
training_misclassification_monitor = MeanOverEpoch(misclassification_node,
callbacks=[])
epoch_logger.subscribe_to('training misclassification %',
training_misclassification_monitor)
# epoch callbacks
# validation_loss_logger = LogsToLists()
def make_output_filename(args, best=False):
basename = make_output_basename(args)
return "{}{}.pkl".format(basename, '_best' if best else "")
model = SerializableModel([input_indices_symbolic], [output_node])
saves_best = SavesAtMinimum(model, make_output_filename(args, best=True))
validation_loss_monitor = MeanOverEpoch(