neon.util.modeldesc.ModelDescription

class neon.util.modeldesc.ModelDescription(pdict)[source]

Bases: dict

Container class for the model serialization dictionary. Provides helper methods for searching and manipulating the dictionary.

Parameters:pdict (dict or str) – the configuration dictionary generated by Model.serialize() or the name of a pickle file containing that dictionary
__init__(pdict)[source]

Methods

__init__(pdict)
clear(() -> None.  Remove all items from D.)
copy(() -> a shallow copy of D)
find_by_name(layers, layer_name) Find a layer by its name.
find_layers(layers, field[, regex]) Print out the layer names in the model with some options for filtering the results.
fromkeys Returns a new dict with keys from iterable and values equal to value.
get((k[,d]) -> D[k] if k in D, …)
getlayer(layer_name) Find a layer by its name.
items(…)
keys(…)
layers([field, regex]) Print out the layer names in the model with some options for filtering the results.
match(o1, o2) Compare two ModelDescription object instances
pop((k[,d]) -> v, …) If key is not found, d is returned if given, otherwise KeyError is raised
popitem(() -> (k, v), …) 2-tuple; but raise KeyError if D is empty.
setdefault((k[,d]) -> D.get(k,d), …)
update(([E, …) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
values(…)
clear() → None. Remove all items from D.
copy() → a shallow copy of D
static find_by_name(layers, layer_name)[source]

Find a layer by its name.

Parameters:
  • layers (dict) – model configuration dictionary
  • layer_name (str) –
Returns:

Layer config dictionary

Return type:

dict

static find_layers(layers, field, regex=None)[source]

Print out the layer names in the model with some options for filtering the results.

Parameters:
  • layers (dict) – model configuration dictionary
  • field (str, optional) – the configuration field to file against (e.g. layer ‘name’)
  • regex (str, optional) – regular expression to apply to field to file the results (e.g. “conv”)
Returns:

Layer config dictionary

Return type:

list of dict

fromkeys()

Returns a new dict with keys from iterable and values equal to value.

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
getlayer(layer_name)[source]

Find a layer by its name.

Parameters:name (str) – name of the layer
Returns:Layer config dictionary
Return type:dict
items() → a set-like object providing a view on D's items
keys() → a set-like object providing a view on D's keys
layers(field='name', regex=None)[source]

Print out the layer names in the model with some options for filtering the results.

Parameters:
  • field (str, optional) – the configuration field to file against (e.g. layer ‘name’)
  • regex (str, optional) – regular expression to apply to field to file the results (e.g. “conv”)

Example

layers(field=’name’, regex=’conv’) will return all layers with the name containing “conv”

static match(o1, o2)[source]

Compare two ModelDescription object instances

Parameters:
Returns:

true if objects match

Return type:

bool

pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → an object providing a view on D's values
version

Print neon version.

Returns:version string
Return type:str