Caffe2 - Python API
A deep learning, cross platform ML framework
Public Member Functions | Public Attributes | List of all members
schema.Struct Class Reference
Inheritance diagram for schema.Struct:
schema.Field

Public Member Functions

def __init__ (self, fields)
 
def get_children (self)
 
def field_names (self)
 
def field_types (self)
 
def field_metadata (self)
 
def field_blobs (self)
 
def all_scalars (self)
 
def has_blobs (self)
 
def clone (self, keep_blobs=True)
 
def __contains__ (self, item)
 
def __len__ (self)
 
def __getitem__ (self, item)
 
def __getattr__ (self, item)
 
def __add__ (self, other)
 
- Public Member Functions inherited from schema.Field
def __init__ (self, children)
 
def clone_schema (self)
 
def field_names (self)
 
def field_types (self)
 
def field_metadata (self)
 
def field_blobs (self)
 
def all_scalars (self)
 
def has_blobs (self)
 
def clone (self, keep_blobs=True)
 
def slice (self)
 
def __eq__ (self, other)
 

Public Attributes

 fields
 

Detailed Description

Represents a named list of fields sharing the same domain.

Definition at line 246 of file schema.py.

Constructor & Destructor Documentation

◆ __init__()

def schema.Struct.__init__ (   self,
  fields 
)
fields is a list of tuples in format of (name, field). The name is
a string of nested name, e.g., `a`, `a:b`, `a:b:c`. For example

Struct(
  ('a', Scalar()),
  ('b:c', Scalar()),
  ('b:d:e', Scalar()),
  ('b', Struct(
    ('f', Scalar()),
  )),
)

is equal to

Struct(
  ('a', Scalar()),
  ('b', Struct(
    ('c', Scalar()),
    ('d', Struct(('e', Scalar()))),
    ('f', Scalar()),
  )),
)

Definition at line 250 of file schema.py.

Member Function Documentation

◆ __add__()

def schema.Struct.__add__ (   self,
  other 
)
Allows to merge fields of two schema.Struct using '+' operator.
If two Struct have common field names, the merge is conducted
recursively. Here are examples:

Example 1
s1 = Struct(('a', Scalar()))
s2 = Struct(('b', Scalar()))
s1 + s2 == Struct(
    ('a', Scalar()),
    ('b', Scalar()),
)

Example 2
s1 = Struct(
    ('a', Scalar()),
    ('b', Struct(('c', Scalar()))),
)
s2 = Struct(('b', Struct(('d', Scalar()))))
s1 + s2 == Struct(
    ('a', Scalar()),
    ('b', Struct(
('c', Scalar()),
('d', Scalar()),
    )),
)

Definition at line 408 of file schema.py.

◆ __getitem__()

def schema.Struct.__getitem__ (   self,
  item 
)
item can be a tuple or list of ints or strings, or a single
int or string. String item is a nested field name, e.g., "a", "a:b",
"a:b:c". Int item is the index of a field at the first level of the
Struct.

Definition at line 376 of file schema.py.


The documentation for this class was generated from the following file: