Caffe2 - Python API
A deep learning, cross platform ML framework
Classes | Functions | Variables
schema Namespace Reference

Module caffe2.python.schema. More...

Classes

class  _SchemaNode
 
class  Field
 
class  List
 
class  Metadata
 
class  Scalar
 
class  Struct
 

Functions

def Map (keys, values, keys_name='keys', values_name='values', lengths_blob=None)
 
def NamedTuple (name_prefix, fields)
 
def Tuple (fields)
 
def RawTuple (num_fields, name_prefix='field')
 
def from_dtype (dtype, _outer_shape=())
 
def from_column_list (col_names, col_types=None, col_blobs=None, col_metadata=None)
 
def from_blob_list (schema, values)
 
def as_record (value)
 
def FetchRecord (blob_record, ws=None)
 
def FeedRecord (blob_record, arrays, ws=None)
 
def NewRecord (net, schema)
 
def ConstRecord (net, array_record)
 
def InitEmptyRecord (net, schema_or_record, enforce_types=False)
 
def is_schema_subset (schema, original_schema)
 
def equal_schemas (schema, original_schema)
 
def schema_check (schema, previous=None)
 
def data_type_for_dtype (dtype)
 
def attach_metadata_to_scalars (field, metadata)
 

Variables

 logger = logging.getLogger(__name__)
 
string FIELD_SEPARATOR = ':'
 
 FeatureSpec
 

Detailed Description

Module caffe2.python.schema.

Function Documentation

◆ ConstRecord()

def schema.ConstRecord (   net,
  array_record 
)
Given a record of arrays, returns a record of blobs,
initialized with net.Const.

Definition at line 931 of file schema.py.

◆ FeedRecord()

def schema.FeedRecord (   blob_record,
  arrays,
  ws = None 
)
Given a Record containing blob_references and arrays, which is either
a list of numpy arrays or a Record containing numpy arrays, feeds the
record to the current workspace.

Definition at line 881 of file schema.py.

◆ FetchRecord()

def schema.FetchRecord (   blob_record,
  ws = None 
)
Given a record containing BlobReferences, return a new record with same
schema, containing numpy arrays, fetched from the current active workspace.

Definition at line 862 of file schema.py.

◆ from_blob_list()

def schema.from_blob_list (   schema,
  values 
)
Create a schema that clones the given schema, but containing the given
list of values.

Definition at line 826 of file schema.py.

◆ from_column_list()

def schema.from_column_list (   col_names,
  col_types = None,
  col_blobs = None,
  col_metadata = None 
)
Given a list of names, types, and optionally values, construct a Schema.

Definition at line 781 of file schema.py.

◆ from_dtype()

def schema.from_dtype (   dtype,
  _outer_shape = () 
)
Constructs a Caffe2 schema from the given numpy's dtype.

Numpy supports scalar, array-like and structured datatypes, as long as
all the shapes are fixed. This function breaks down the given dtype into
a Caffe2 schema containing `Struct` and `Scalar` types.

Fields containing byte offsets are not currently supported.

Definition at line 675 of file schema.py.

◆ Map()

def schema.Map (   keys,
  values,
  keys_name = 'keys',
  values_name = 'values',
  lengths_blob = None 
)
A map is a List of Struct containing keys and values fields.
Optionally, you can provide custom name for the key and value fields.

Definition at line 644 of file schema.py.

◆ NewRecord()

def schema.NewRecord (   net,
  schema 
)
Given a record of np.arrays, create a BlobReference for each one of them,
returning a record containing BlobReferences. The name of each returned blob
is NextScopedBlob(field_name), which guarantees unique name in the current
net. Use NameScope explicitly to avoid name conflictions between different
nets.

Definition at line 908 of file schema.py.

◆ RawTuple()

def schema.RawTuple (   num_fields,
  name_prefix = 'field' 
)
Creates a tuple of `num_field` untyped scalars.

Definition at line 666 of file schema.py.

◆ Tuple()

def schema.Tuple (   fields)
Creates a Struct with default, sequential, field names of given types.

Definition at line 659 of file schema.py.

Variable Documentation

◆ FeatureSpec

schema.FeatureSpec
Initial value:
1 = namedtuple(
2  'FeatureSpec',
3  ['feature_type', 'feature_names', 'feature_ids', 'feature_is_request_only']
4 )

Definition at line 55 of file schema.py.