models.datatypes

Basic Data Types.

Module Contents

Classes

_DatatypeBase(self,type_tag,full_tag,num_elements)
Int64(self) Int64 Data Type
Double(self) Double Data Type
String(self) String Data Type
Array(self,*dimensions) Array Data Type
Dictionary(self,key_type=None) Dictionary Data Type

Functions

_is_valid_datatype(datatype_instance) Returns true if datatype_instance is a valid datatype object and false otherwise.
_normalize_datatype(datatype_instance) Translates a user specified datatype to an instance of the ones defined above.
_set_datatype(proto_type_obj,datatype_instance)
class _DatatypeBase(type_tag, full_tag, num_elements)
__init__(type_tag, full_tag, num_elements)
__eq__(other)
__ne__(other)
__hash__()
__repr__()
class Int64

Int64 Data Type

__init__()
class Double

Double Data Type

__init__()
class String

String Data Type

__init__()
class Array(*dimensions)

Array Data Type

__init__(*dimensions)

Constructs a Array, given its dimensions

dimensions: ints | longs

# Create a single dimensions array of length five >>> arr = coremltools.models.datatypes.Array(5)

# Create a multi dimension array five by two by ten. >>> multi_arr = coremltools.models.datatypes.Array(5, 2, 10)

class Dictionary(key_type=None)

Dictionary Data Type

__init__(key_type=None)

Constructs a Dictionary, given its key type

key_type: Int64 | String

>>> from coremltools.models.datatypes import Dictionary, Int64, String

# Create a dictionary with string keys >>> str_key_dict = Dictionary(key_type=String)

# Create a dictionary with int keys >>> int_key_dict = Dictionary(Int64)

_is_valid_datatype(datatype_instance)

Returns true if datatype_instance is a valid datatype object and false otherwise.

_normalize_datatype(datatype_instance)

Translates a user specified datatype to an instance of the ones defined above.

Valid data types are passed through, and the following type specifications are translated to the proper instances:

str, “String” -> String() int, “Int64” -> Int64() float, “Double” -> Double()

If a data type is not recognized, then an error is raised.

_set_datatype(proto_type_obj, datatype_instance)