本文整理汇总了Python中util.info方法的典型用法代码示例。如果您正苦于以下问题:Python util.info方法的具体用法?Python util.info怎么用?Python util.info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util
的用法示例。
在下文中一共展示了util.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def list(self, url, filter=None):
util.info("Examining url " + url)
list_result = None
if FILTER_URL_PARAM in url:
list_result = self.list_movies_by_dubbing(url)
elif not filter and DUBBING_URL_PARAM in url:
list_result = self.list_dubbing(url)
elif J_MOVIES_A_TO_Z_TYPE in url or J_MOVIES_GENRE in url:
list_result = self.load_json_list(url)
elif J_SERIES in url:
list_result = self.list_episodes(url)
elif J_TV_SHOWS in url or J_TV_SHOWS_MOST_POPULAR in url:
list_result = self.list_series_letter(url)
elif J_TV_SHOWS_RECENTLY_ADDED in url:
list_result = self.list_recentlyadded_episodes(url)
elif J_TV_SHOWS_A_TO_Z_TYPE in url:
list_result = self.a_to_z(J_TV_SHOWS)
else:
order_by = None
if J_MOVIES_RECENTLY_ADDED in url:
order_by = self.order_recently_by
list_result = self.list_videos(url, filter, order_by)
return list_result
示例2: train
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def train(self, state, legal_moves, winner=False):
assert self.memory is not None, "can't train without setting memory first"
self.train_count += 1
model = self.model
if self.prev_state is None:
# on first move, no training to do yet
self.prev_state = state
else:
# add new info to replay memory
reward = 0
if winner == self.color:
reward = WIN_REWARD
elif winner == opponent[self.color]:
reward = LOSE_REWARD
elif winner is not False:
raise ValueError
self.memory.remember(self.prev_state, self.prev_move,
reward, state, legal_moves, winner)
# get an experience from memory and train on it
if self.train_count % BATCH_SIZE == 0 or winner is not False:
states, targets = self.memory.get_replay(
model, BATCH_SIZE, ALPHA)
model.train_on_batch(states, targets)
示例3: get_model
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def get_model(self, filename=None):
"""Given a filename, load that model file; otherwise, generate a new model."""
model = None
if filename:
info('attempting to load model {}'.format(filename))
try:
model = model_from_json(open(filename).read())
except FileNotFoundError:
print('could not load file {}'.format(filename))
quit()
print('loaded model file {}'.format(filename))
else:
print('no model file loaded, generating new model.')
size = self.reversi.size ** 2
model = Sequential()
model.add(Dense(HIDDEN_SIZE, activation='relu', input_dim=size))
# model.add(Dense(HIDDEN_SIZE, activation='relu'))
model.add(Dense(size))
model.compile(loss='mse', optimizer=optimizer)
return model
示例4: tick
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def tick (self, flow_now = None):
now = time.time()
if ((self.max_ticks is not None and self.ticks == self.max_ticks) or
(self.max_time is not None and now > self.start + self.max_time)):
raise Done()
self.ticks += 1
if flow_now is not None:
self.flow_now = flow_now
if ((self.tick_report is not None and
self.ticks - self.last_report_ticks >= self.tick_report) or
(self.flow_report is not None and self.flow_now is not None and
((self.flow_now - self.last_report_flow).total_seconds()
>= self.flow_report)) or
(self.time_report is not None and
now - self.last_report_time >= self.time_report)):
self.logger.info("%s",self.report())
self.last_report_time = now
self.last_report_ticks = self.ticks
self.last_report_flow = self.flow_now
示例5: request_last_update
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def request_last_update(self, url):
util.debug('request: %s' % url)
lastmod = None
req = urllib2.Request(url)
req.add_header('User-Agent', util.UA)
try:
response = urllib2.urlopen(req)
lastmod = datetime.datetime(*response.info().getdate('Last-Modified')[:6]).strftime(
'%d.%m.%Y')
response.close()
except urllib2.HTTPError, error:
util.debug(error.read())
error.close()
示例6: service
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def service(self):
util.info("SOSAC Service Started")
try:
sleep_time = int(self.getSetting("start_sleep_time")) * 1000 * 60 * 60
except:
sleep_time = self.sleep_time
pass
self.sleep(sleep_time)
try:
self.last_run = float(self.cache.get("subscription.last_run"))
except:
self.last_run = time.time()
self.cache.set("subscription.last_run", str(self.last_run))
pass
if not xbmc.abortRequested and time.time() > self.last_run:
self.evalSchedules()
while not xbmc.abortRequested:
# evaluate subsciptions every 10 minutes
if(time.time() > self.last_run + 600):
self.evalSchedules()
self.last_run = time.time()
self.cache.set("subscription.last_run", str(self.last_run))
self.sleep(self.sleep_time)
util.info("SOSAC Shutdown")
示例7: evalSchedules
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def evalSchedules(self):
if not self.scanRunning() and not self.isPlaying():
notified = False
util.info("SOSAC Loading subscriptions")
subs = self.get_subs()
new_items = False
for url, sub in subs.iteritems():
if xbmc.abortRequested:
util.info("SOSAC Exiting")
return
if sub['type'] == sosac.LIBRARY_TYPE_TVSHOW:
if self.scanRunning() or self.isPlaying():
self.cache.delete("subscription.last_run")
return
refresh = int(sub['refresh'])
if refresh > 0:
next_check = sub['last_run'] + (refresh * 3600 * 24)
if next_check < time.time():
if not notified:
self.showNotification(
'Subscription', 'Chcecking')
notified = True
util.debug("SOSAC Refreshing " + url)
new_items |= self.run_custom({
'action': sosac.LIBRARY_ACTION_ADD,
'type': sosac.LIBRARY_TYPE_TVSHOW,
'update': True,
'url': url,
'name': sub['name'],
'refresh': sub['refresh']
})
self.sleep(3000)
else:
n = (next_check - time.time()) / 3600
util.debug("SOSAC Skipping " + url +
" , next check in %dh" % n)
if new_items:
xbmc.executebuiltin('UpdateLibrary(video)')
notified = False
else:
util.info("SOSAC Scan skipped")
示例8: set_epsilon
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def set_epsilon(self, val):
self.epsilon = val
if not self.learning_enabled:
info('Warning -- set_epsilon() was called when learning was not enabled.')
示例9: policy
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def policy(self, state, legal_moves):
"""The policy of picking an action based on their weights."""
if not legal_moves:
return None
if not self.minimax_enabled:
# don't use minimax if we're in learning mode
best_move, _ = best_move_val(
self.model.predict(numpify(state)),
legal_moves
)
return best_move
else:
next_states = {self.reversi.next_state(
state, move): move for move in legal_moves}
move_scores = []
for s in next_states.keys():
score = self.minimax(s)
move_scores.append((score, s))
info('{}: {}'.format(next_states[s], score))
best_val = -float('inf')
best_move = None
for each in move_scores:
if each[0] > best_val:
best_val = each[0]
best_move = next_states[each[1]]
assert best_move is not None
return best_move
示例10: timing
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def timing (func, logger = None):
start = time.time()
ret = func()
util.info("Ran %s in %s" % (func, elapsed(start)),logger=logger)
return ret
示例11: compile_file_list
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def compile_file_list(self, data_dir, split, load_pose=False):
"""Creates a list of input files."""
logging.info('data_dir: %s', data_dir)
with gfile.Open(os.path.join(data_dir, '%s.txt' % split), 'r') as f:
frames = f.readlines()
frames = [k.rstrip() for k in frames]
subfolders = [x.split(' ')[0] for x in frames]
frame_ids = [x.split(' ')[1] for x in frames]
image_file_list = [
os.path.join(data_dir, subfolders[i], frame_ids[i] + '.' +
self.file_extension)
for i in range(len(frames))
]
segment_file_list = [
os.path.join(data_dir, subfolders[i], frame_ids[i] + '-fseg.' +
self.file_extension)
for i in range(len(frames))
]
cam_file_list = [
os.path.join(data_dir, subfolders[i], frame_ids[i] + '_cam.txt')
for i in range(len(frames))
]
file_lists = {}
file_lists['image_file_list'] = image_file_list
file_lists['segment_file_list'] = segment_file_list
file_lists['cam_file_list'] = cam_file_list
if load_pose:
pose_file_list = [
os.path.join(data_dir, subfolders[i], frame_ids[i] + '_pose.txt')
for i in range(len(frames))
]
file_lists['pose_file_list'] = pose_file_list
self.steps_per_epoch = len(image_file_list) // self.batch_size
return file_lists
示例12: build_inference_for_training
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def build_inference_for_training(self):
"""Invokes depth and ego-motion networks and computes clouds if needed."""
(self.image_stack, self.intrinsic_mat, self.intrinsic_mat_inv) = (
self.reader.read_data())
with tf.name_scope('egomotion_prediction'):
self.egomotion, _ = nets.egomotion_net(self.image_stack, is_training=True,
legacy_mode=self.legacy_mode)
with tf.variable_scope('depth_prediction'):
# Organized by ...[i][scale]. Note that the order is flipped in
# variables in build_loss() below.
self.disp = {}
self.depth = {}
if self.icp_weight > 0:
self.cloud = {}
for i in range(self.seq_length):
image = self.image_stack[:, :, :, 3 * i:3 * (i + 1)]
multiscale_disps_i, _ = nets.disp_net(image, is_training=True)
multiscale_depths_i = [1.0 / d for d in multiscale_disps_i]
self.disp[i] = multiscale_disps_i
self.depth[i] = multiscale_depths_i
if self.icp_weight > 0:
multiscale_clouds_i = [
project.get_cloud(d,
self.intrinsic_mat_inv[:, s, :, :],
name='cloud%d_%d' % (s, i))
for (s, d) in enumerate(multiscale_depths_i)
]
self.cloud[i] = multiscale_clouds_i
# Reuse the same depth graph for all images.
tf.get_variable_scope().reuse_variables()
logging.info('disp: %s', util.info(self.disp))
示例13: compile_file_list
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def compile_file_list(self, data_dir, split, load_pose=False):
"""Creates a list of input files."""
logging.info('data_dir: %s', data_dir)
with gfile.Open(os.path.join(data_dir, '%s.txt' % split), 'r') as f:
frames = f.readlines()
subfolders = [x.split(' ')[0] for x in frames]
frame_ids = [x.split(' ')[1][:-1] for x in frames]
image_file_list = [
os.path.join(data_dir, subfolders[i], frame_ids[i] + '.jpg')
for i in range(len(frames))
]
cam_file_list = [
os.path.join(data_dir, subfolders[i], frame_ids[i] + '_cam.txt')
for i in range(len(frames))
]
file_lists = {}
file_lists['image_file_list'] = image_file_list
file_lists['cam_file_list'] = cam_file_list
if load_pose:
pose_file_list = [
os.path.join(data_dir, subfolders[i], frame_ids[i] + '_pose.txt')
for i in range(len(frames))
]
file_lists['pose_file_list'] = pose_file_list
self.steps_per_epoch = len(image_file_list) // self.batch_size
return file_lists
示例14: main
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def main():
logger.info("Checking your OS version...")
if util.check_os():
logger.info("OK")
else:
logger.critical("You must use Ubuntu 14.04")
if util.not_sudo():
logger.critical("Restart script as root")
logger.info("Installing packages...")
if util.install_packages():
logger.info("OK")
else:
logger.critical("Failed to install packages")
logger.info("Applying sysctl parameters...")
if util.setup_sysctl():
logger.info("OK")
else:
logger.critical("Failed to apply sysctl parameters")
logger.info("Creating random passwords...")
if util.setup_passwords():
logger.info("OK")
else:
logger.critical("Failed to create random passwords")
logger.info("Other config files...")
if util.cp_configs():
logger.info("OK")
else:
logger.critical("Fail")
logger.info("Adding script to rc.local...")
if util.setup_vpn():
logger.info("OK")
else:
logger.critical("Failed adding script to rc.local")
logger.info("Installing web UI...")
if util.webui():
logger.info("OK")
else:
logger.critical("Failed installing web UI")
util.info()
示例15: __init__
# 需要导入模块: import util [as 别名]
# 或者: from util import info [as 别名]
def __init__(self,
data_dir=None,
is_training=True,
learning_rate=0.0002,
beta1=0.9,
reconstr_weight=0.85,
smooth_weight=0.05,
ssim_weight=0.15,
icp_weight=0.0,
batch_size=4,
img_height=128,
img_width=416,
seq_length=3,
legacy_mode=False):
self.data_dir = data_dir
self.is_training = is_training
self.learning_rate = learning_rate
self.reconstr_weight = reconstr_weight
self.smooth_weight = smooth_weight
self.ssim_weight = ssim_weight
self.icp_weight = icp_weight
self.beta1 = beta1
self.batch_size = batch_size
self.img_height = img_height
self.img_width = img_width
self.seq_length = seq_length
self.legacy_mode = legacy_mode
logging.info('data_dir: %s', data_dir)
logging.info('learning_rate: %s', learning_rate)
logging.info('beta1: %s', beta1)
logging.info('smooth_weight: %s', smooth_weight)
logging.info('ssim_weight: %s', ssim_weight)
logging.info('icp_weight: %s', icp_weight)
logging.info('batch_size: %s', batch_size)
logging.info('img_height: %s', img_height)
logging.info('img_width: %s', img_width)
logging.info('seq_length: %s', seq_length)
logging.info('legacy_mode: %s', legacy_mode)
if self.is_training:
self.reader = reader.DataReader(self.data_dir, self.batch_size,
self.img_height, self.img_width,
self.seq_length, NUM_SCALES)
self.build_train_graph()
else:
self.build_depth_test_graph()
self.build_egomotion_test_graph()
# At this point, the model is ready. Print some info on model params.
util.count_parameters()