本文整理汇总了Python中tensorlayer.logging.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(
self, #prev_layer,
center=True,
scale=True,
act=None,
# reuse=None,
# variables_collections=None,
# outputs_collections=None,
# trainable=True,
epsilon=1e-12,
begin_norm_axis=1,
begin_params_axis=-1,
beta_init=tl.initializers.zeros(),
gamma_init=tl.initializers.ones(),
data_format='channels_last',
name=None,
):
# super(LayerNorm, self).__init__(prev_layer=prev_layer, act=act, name=name)
super(LayerNorm, self).__init__(name)
self.center = center
self.scale = scale
self.act = act
self.epsilon = epsilon
self.begin_norm_axis = begin_norm_axis
self.begin_params_axis = begin_params_axis
self.beta_init = beta_init
self.gamma_init = gamma_init
self.data_format = data_format
logging.info(
"LayerNorm %s: act: %s" % (self.name, self.act.__name__ if self.act is not None else 'No Activation')
)
示例2: __init__
def __init__(
self,
n_units,
act=None,
W_init=tl.initializers.truncated_normal(stddev=0.1),
b_init=tl.initializers.constant(value=0.0),
in_channels=None,
name=None, # 'dense',
):
super(Dense, self).__init__(name)
self.n_units = n_units
self.act = act
self.W_init = W_init
self.b_init = b_init
self.in_channels = in_channels
if self.in_channels is not None:
self.build(self.in_channels)
self._built = True
logging.info(
"Dense %s: %d %s" %
(self.name, self.n_units, self.act.__name__ if self.act is not None else 'No Activation')
)
示例3: __init__
def __init__(
self,
act=None,
shape=(5, 1, 5),
stride=1,
padding='SAME',
data_format='NWC',
dilation_rate=1,
W_init=tl.initializers.truncated_normal(stddev=0.02),
b_init=tl.initializers.constant(value=0.0),
name=None # 'cnn1d_layer',
):
super().__init__(name)
self.act = act
self.n_filter = shape[-1]
self.filter_size = shape[0]
self.shape = shape
self.stride = stride
self.dilation_rate = dilation_rate
self.padding = padding
self.data_format = data_format
self.W_init = W_init
self.b_init = b_init
self.in_channels = shape[-2]
self.build(None)
self._built = True
logging.info(
"Conv1dLayer %s: shape: %s stride: %s pad: %s act: %s" % (
self.name, str(shape), str(stride), padding,
self.act.__name__ if self.act is not None else 'No Activation'
)
)
示例4: __init__
def __init__(
self,
keep=0.5,
n_units=100,
act=None,
W_init=tl.initializers.truncated_normal(stddev=0.1),
b_init=tl.initializers.constant(value=0.0),
in_channels=None,
name=None, # 'dropconnect',
):
super().__init__(name)
if isinstance(keep, numbers.Real) and not (keep > 0 and keep <= 1):
raise ValueError("keep must be a scalar tensor or a float in the "
"range (0, 1], got %g" % keep)
self.keep = keep
self.n_units = n_units
self.act = act
self.W_init = W_init
self.b_init = b_init
self.in_channels = in_channels
if self.in_channels is not None:
self.build((None, self.in_channels))
self._built = True
logging.info(
"DropconnectDense %s: %d %s" %
(self.name, n_units, self.act.__name__ if self.act is not None else 'No Activation')
)
示例5: __init__
def __init__(
self,
fw_cell,
bw_cell,
return_seq_2d=False,
return_state=False,
in_channels=None,
name=None, # 'birnn'
):
super(BiRNN, self).__init__(name)
self.fw_cell = fw_cell
self.bw_cell = bw_cell
self.return_seq_2d = return_seq_2d
self.return_state = return_state
if in_channels is not None:
self.build((None, None, in_channels))
self._built = True
logging.info(
"BiRNN %s: fw_cell: %s, fw_n_units: %s, bw_cell: %s, bw_n_units: %s" % (
self.name, self.fw_cell.__class__.__name__, self.fw_cell.units, self.bw_cell.__class__.__name__,
self.bw_cell.units
)
)
示例6: load_nietzsche_dataset
def load_nietzsche_dataset(path='data'):
"""Load Nietzsche dataset.
Parameters
----------
path : str
The path that the data is downloaded to, defaults is ``data/nietzsche/``.
Returns
--------
str
The content.
Examples
--------
>>> see tutorial_generate_text.py
>>> words = tl.files.load_nietzsche_dataset()
>>> words = basic_clean_str(words)
>>> words = words.split()
"""
logging.info("Load or Download nietzsche dataset > {}".format(path))
path = os.path.join(path, 'nietzsche')
filename = "nietzsche.txt"
url = 'https://s3.amazonaws.com/text-datasets/'
filepath = maybe_download_and_extract(filename, path, url)
with open(filepath, "r") as f:
words = f.read()
return words
示例7: __init__
def __init__(self, name=None): #'flatten'):
super(Flatten, self).__init__(name)
self.build()
self._built = True
logging.info("Flatten %s:" % (self.name))
示例8: __init__
def __init__(
self,
n_units=100,
act=None,
bitW=8,
bitA=8,
use_gemm=False,
W_init=tl.initializers.truncated_normal(stddev=0.1),
b_init=tl.initializers.constant(value=0.0),
in_channels=None,
name=None, #'quan_dense',
):
super().__init__(name)
self.n_units = n_units
self.act = act
self.bitW = bitW
self.bitA = bitA
self.use_gemm = use_gemm
self.W_init = W_init
self.b_init = b_init
self.in_channels = in_channels
if self.in_channels is not None:
self.build((None, self.in_channels))
self._built = True
logging.info(
"QuanDense %s: %d %s" %
(self.name, n_units, self.act.__name__ if self.act is not None else 'No Activation')
)
示例9: __init__
def __init__(
self,
vocabulary_size,
embedding_size,
num_sampled=64,
activate_nce_loss=True,
nce_loss_args=None,
E_init=tl.initializers.random_uniform(minval=-1.0, maxval=1.0),
nce_W_init=tl.initializers.truncated_normal(stddev=0.03),
nce_b_init=tl.initializers.constant(value=0.0),
name=None, #'word2vec',
):
super(Word2vecEmbedding, self).__init__(name)
self.vocabulary_size = vocabulary_size
self.embedding_size = embedding_size
self.num_sampled = num_sampled
self.E_init = E_init
self.activate_nce_loss = activate_nce_loss
if self.activate_nce_loss:
self.nce_loss_args = nce_loss_args
self.nce_W_init = nce_W_init
self.nce_b_init = nce_b_init
if not self._built:
self.build(tuple())
self._built = True
logging.info("Word2vecEmbedding %s: (%d, %d)" % (self.name, self.vocabulary_size, self.embedding_size))
示例10: load_celebA_dataset
def load_celebA_dataset(path='data'):
"""Load CelebA dataset
Return a list of image path.
Parameters
-----------
path : str
The path that the data is downloaded to, defaults is ``data/celebA/``.
"""
data_dir = 'celebA'
filename, drive_id = "img_align_celeba.zip", "0B7EVK8r0v71pZjFTYXZWM3FlRnM"
save_path = os.path.join(path, filename)
image_path = os.path.join(path, data_dir)
if os.path.exists(image_path):
logging.info('[*] {} already exists'.format(save_path))
else:
exists_or_mkdir(path)
download_file_from_google_drive(drive_id, save_path)
zip_dir = ''
with zipfile.ZipFile(save_path) as zf:
zip_dir = zf.namelist()[0]
zf.extractall(path)
os.remove(save_path)
os.rename(os.path.join(path, zip_dir), image_path)
data_files = load_file_list(path=image_path, regx='\\.jpg', printable=False)
for i, _v in enumerate(data_files):
data_files[i] = os.path.join(image_path, data_files[i])
return data_files
示例11: gunzip_file
def gunzip_file(gz_path, new_path):
"""Unzips from gz_path into new_path."""
logging.info("Unpacking %s to %s" % (gz_path, new_path))
with gzip.open(gz_path, "rb") as gz_file:
with open(new_path, "wb") as new_file:
for line in gz_file:
new_file.write(line)
示例12: __init__
def __init__(
self,
offset_layer=None,
# shape=(3, 3, 1, 100),
n_filter=32,
filter_size=(3, 3),
act=None,
padding='SAME',
W_init=tl.initializers.truncated_normal(stddev=0.02),
b_init=tl.initializers.constant(value=0.0),
in_channels=None,
name=None # 'deformable_conv_2d',
):
super().__init__(name)
self.offset_layer = offset_layer
self.n_filter = n_filter
self.filter_size = filter_size
self.act = act
self.padding = padding
self.W_init = W_init
self.b_init = b_init
self.in_channels = in_channels
self.kernel_n = filter_size[0] * filter_size[1]
if self.offset_layer.get_shape()[-1] != 2 * self.kernel_n:
raise AssertionError("offset.get_shape()[-1] is not equal to: %d" % 2 * self.kernel_n)
logging.info(
"DeformableConv2d %s: n_filter: %d, filter_size: %s act: %s" %
(self.name, self.n_filter, str(self.filter_size), self.act.__name__ if self.act is not None else 'No Activation')
)
示例13: __init__
def __init__(self, num=None, axis=0, name=None): #'unstack'):
super().__init__(name)
self.num = num
self.axis = axis
self.build(None)
self._built = True
logging.info("UnStack %s: num: %s axis: %d" % (self.name, self.num, self.axis))
示例14: find_top_dataset
def find_top_dataset(self, dataset_name=None, sort=None, **kwargs):
"""Finds and returns a dataset from the database which matches the requirement.
Parameters
----------
dataset_name : str
The name of dataset.
sort : List of tuple
PyMongo sort comment, search "PyMongo find one sorting" and `collection level operations <http://api.mongodb.com/python/current/api/pymongo/collection.html>`__ for more details.
kwargs : other events
Other events, such as description, author and etc (optinal).
Examples
---------
Save dataset
>>> db.save_dataset([X_train, y_train, X_test, y_test], 'mnist', description='this is a tutorial')
Get dataset
>>> dataset = db.find_top_dataset('mnist')
>>> datasets = db.find_datasets('mnist')
Returns
--------
dataset : the dataset or False
Return False if nothing found.
"""
self._fill_project_info(kwargs)
if dataset_name is None:
raise Exception("dataset_name is None, please give a dataset name")
kwargs.update({'dataset_name': dataset_name})
s = time.time()
d = self.db.Dataset.find_one(filter=kwargs, sort=sort)
if d is not None:
dataset_id = d['dataset_id']
else:
print("[Database] FAIL! Cannot find dataset: {}".format(kwargs))
return False
try:
dataset = self._deserialization(self.dataset_fs.get(dataset_id).read())
pc = self.db.Dataset.find(kwargs)
print("[Database] Find one dataset SUCCESS, {} took: {}s".format(kwargs, round(time.time() - s, 2)))
# check whether more datasets match the requirement
dataset_id_list = pc.distinct('dataset_id')
n_dataset = len(dataset_id_list)
if n_dataset != 1:
print(" Note that there are {} datasets match the requirement".format(n_dataset))
return dataset
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
logging.info("{} {} {} {} {}".format(exc_type, exc_obj, fname, exc_tb.tb_lineno, e))
return False
示例15: restore_params
def restore_params(network, path='models'):
logging.info("Restore pre-trained parameters")
maybe_download_and_extract(
'squeezenet.npz', path, 'https://github.com/tensorlayer/pretrained-models/raw/master/models/',
expected_bytes=7405613
) # ls -al
params = load_npz(name=os.path.join(path, 'squeezenet.npz'))
assign_weights(params[:len(network.weights)], network)
del params