in tensorflow_examples/models/densenet/densenet.py [0:0]
def calc_from_list(depth, num_blocks, layers_per_block):
"""Calculate number of layers in each block.
Args:
depth: Depth of model
num_blocks: Number of dense blocks
layers_per_block: Number of layers per block as a list or tuple
Returns:
Number of layers in each block as a list
Raises:
ValueError: If depth or num_blocks is not None and
layers_per_block is None or not a list or tuple
"""
if depth is not None or num_blocks is not None:
raise ValueError("You don't have to specify the depth and number of "
"blocks when mode is 'from_list'")
if layers_per_block is None or not isinstance(
layers_per_block, list) or not isinstance(layers_per_block, tuple):
raise ValueError("You must pass list or tuple when using 'from_list' mode.")
if isinstance(layers_per_block, list) or isinstance(layers_per_block, tuple):
return list(layers_per_block)