CollectionDef should cover most collections.
To add a user-defined collection, do one of the following:
1. For simple data types, such as string, int, float:
tf.add_to_collection("your_collection_name", your_simple_value)
strings will be stored as bytes_list.
2. For Protobuf types, there are three ways to add them:
1) tf.add_to_collection("your_collection_name",
your_proto.SerializeToString())
collection_def {
key: "user_defined_bytes_collection"
value {
bytes_list {
value: "queue_name: \"test_queue\"\n"
}
}
}
or
2) tf.add_to_collection("your_collection_name", str(your_proto))
collection_def {
key: "user_defined_string_collection"
value {
bytes_list {
value: "\n\ntest_queue"
}
}
}
or
3) any_buf = any_pb2.Any()
tf.add_to_collection("your_collection_name",
any_buf.Pack(your_proto))
collection_def {
key: "user_defined_any_collection"
value {
any_list {
value {
type_url: "type.googleapis.com/tensorflow.QueueRunnerDef"
value: "\n\ntest_queue"
}
}
}
}
3. For Python objects, implement to_proto() and from_proto(), and register
them in the following manner:
ops.register_proto_function("your_collection_name",
proto_type,
to_proto=YourPythonObject.to_proto,
from_proto=YourPythonObject.from_proto)
These functions will be invoked to serialize and de-serialize the
collection. For example,
ops.register_proto_function(ops.GraphKeys.GLOBAL_VARIABLES,
proto_type=variable_pb2.VariableDef,
to_proto=Variable.to_proto,
from_proto=Variable.from_proto)
tensorflow.CollectionDef Các lớp lồng nhau
| lớp học | CollectionDef.AnyList | AnyList is used for collecting Any protos. | |
| giao diện | CollectionDef.AnyListOrBuilder | ||
| lớp học | Bộ sưu tậpDef.Builder | CollectionDef should cover most collections. | |
| lớp học | CollectionDef.BytesList | BytesList is used for collecting strings and serialized protobufs. | |
| giao diện | CollectionDef.BytesListOrBuilder | ||
| lớp học | CollectionDef.FloatList | FloatList is used for collecting float values. | |
| giao diện | CollectionDef.FloatListOrBuilder | ||
| lớp học | Bộ sưu tậpDef.Int64List | Int64List is used for collecting int, int64 and long values. | |
| giao diện | CollectionDef.Int64ListOrBuilder | ||
| liệt kê | Bộ sưu tậpDef.KindCase | ||
| lớp học | Bộ sưu tậpDef.NodeList | NodeList is used for collecting nodes in graph. | |
| giao diện | CollectionDef.NodeListOrBuilder | ||
Hằng số
| int | BẤT CỨ_LIST_FIELD_NUMBER | |
| int | BYTES_LIST_FIELD_NUMBER | |
| int | FLOAT_LIST_FIELD_NUMBER | |
| int | INT64_LIST_FIELD_NUMBER | |
| int | NODE_LIST_FIELD_NUMBER |
Phương pháp công cộng
| boolean | bằng (Đối tượng obj) |
| CollectionDef.AnyList | getAnyList () .tensorflow.CollectionDef.AnyList any_list = 5; |
| CollectionDef.AnyListOrBuilder | getAnyListOrBuilder () .tensorflow.CollectionDef.AnyList any_list = 5; |
| CollectionDef.BytesList | getBytesList () .tensorflow.CollectionDef.BytesList bytes_list = 2; |
| CollectionDef.BytesListOrBuilder | getBytesListOrBuilder () .tensorflow.CollectionDef.BytesList bytes_list = 2; |
| Bộ sưu tập tĩnh | |
| Bộ sưu tậpDef | |
| com.google.protobuf.Descriptors.Descriptor tĩnh cuối cùng | |
| CollectionDef.FloatList | getFloatList () .tensorflow.CollectionDef.FloatList float_list = 4; |
| CollectionDef.FloatListOrBuilder | getFloatListOrBuilder () .tensorflow.CollectionDef.FloatList float_list = 4; |
| Bộ sưu tậpDef.Int64List | getInt64List () .tensorflow.CollectionDef.Int64List int64_list = 3; |
| CollectionDef.Int64ListOrBuilder | getInt64ListOrBuilder () .tensorflow.CollectionDef.Int64List int64_list = 3; |
| Bộ sưu tậpDef.KindCase | getKindCase () |
| Bộ sưu tậpDef.NodeList | getNodeList () .tensorflow.CollectionDef.NodeList node_list = 1; |
| CollectionDef.NodeListOrBuilder | getNodeListOrBuilder () .tensorflow.CollectionDef.NodeList node_list = 1; |
| int | |
| com.google.protobuf.UnknownFieldSet cuối cùng | |
| boolean | hasAnyList () .tensorflow.CollectionDef.AnyList any_list = 5; |
| boolean | hasBytesList () .tensorflow.CollectionDef.BytesList bytes_list = 2; |
| boolean | hasFloatList () .tensorflow.CollectionDef.FloatList float_list = 4; |
| boolean | hasInt64List () .tensorflow.CollectionDef.Int64List int64_list = 3; |
| boolean | hasNodeList () .tensorflow.CollectionDef.NodeList node_list = 1; |
| int | mã băm () |
| boolean cuối cùng | |
| Bộ sưu tập tĩnhDef.Builder | newBuilder (nguyên mẫu CollectionDef ) |
| Bộ sưu tập tĩnhDef.Builder | |
| Bộ sưu tậpDef.Builder | |
| Bộ sưu tập tĩnh | phân tích cú phápDelimitedFrom (Đầu vào luồng đầu vào) |
| Bộ sưu tập tĩnh | phân tích cú phápDelimitedFrom (Đầu vào luồng đầu vào, com.google.protobuf.ExtensionRegistryLite tiện ích mở rộngRegistry) |
| Bộ sưu tập tĩnh | ParseFrom (dữ liệu ByteBuffer) |
| Bộ sưu tập tĩnh | ParseFrom (đầu vào com.google.protobuf.CodedInputStream, com.google.protobuf.ExtensionRegistryLite ExtensionRegistry) |
| Bộ sưu tập tĩnh | ParseFrom (Dữ liệu ByteBuffer, com.google.protobuf.ExtensionRegistryLite ExtensionRegistry) |
| Bộ sưu tập tĩnh | ParseFrom (đầu vào com.google.protobuf.CodedInputStream) |
| Bộ sưu tập tĩnh | ParseFrom (dữ liệu byte[], com.google.protobuf.ExtensionRegistryLite ExtensionRegistry) |
| Bộ sưu tập tĩnh | ParseFrom (dữ liệu com.google.protobuf.ByteString) |
| Bộ sưu tập tĩnh | ParseFrom (Đầu vào inputStream, com.google.protobuf.ExtensionRegistryLite ExtensionRegistry) |
| Bộ sưu tập tĩnh | ParseFrom (dữ liệu com.google.protobuf.ByteString, com.google.protobuf.ExtensionRegistryLite ExtensionRegistry) |
| tĩnh | |
| Bộ sưu tậpDef.Builder | toBuilder () |
| trống rỗng | writeTo (đầu ra com.google.protobuf.CodedOutputStream) |
Phương pháp kế thừa
Hằng số
int tĩnh công khai ANY_LIST_FIELD_NUMBER
int tĩnh công khai BYTES_LIST_FIELD_NUMBER
int tĩnh công khai FLOAT_LIST_FIELD_NUMBER
int tĩnh công khai INT64_LIST_FIELD_NUMBER
int tĩnh công khai NODE_LIST_FIELD_NUMBER
Phương pháp công cộng
boolean công khai bằng (Object obj)
public CollectionDef.AnyListOrBuilder getAnyListOrBuilder ()
.tensorflow.CollectionDef.AnyList any_list = 5;
CollectionDef.BytesList getBytesList công khai ()
.tensorflow.CollectionDef.BytesList bytes_list = 2;
public CollectionDef.BytesListOrBuilder getBytesListOrBuilder ()
.tensorflow.CollectionDef.BytesList bytes_list = 2;
công khai tĩnh cuối cùng com.google.protobuf.Descriptors.Descriptor getDescriptor ()
public CollectionDef.FloatListOrBuilder getFloatListOrBuilder ()
.tensorflow.CollectionDef.FloatList float_list = 4;
CollectionDef.Int64List getInt64List công khai ()
.tensorflow.CollectionDef.Int64List int64_list = 3;
public CollectionDef.Int64ListOrBuilder getInt64ListOrBuilder ()
.tensorflow.CollectionDef.Int64List int64_list = 3;
public CollectionDef.NodeListOrBuilder getNodeListOrBuilder ()
.tensorflow.CollectionDef.NodeList node_list = 1;
công cộng getParserForType ()
int công khai getSerializedSize ()
trận chung kết công khai com.google.protobuf.UnknownFieldSet getUnknownFields ()
boolean công khai hasAnyList ()
.tensorflow.CollectionDef.AnyList any_list = 5;
boolean công khai hasBytesList ()
.tensorflow.CollectionDef.BytesList bytes_list = 2;
boolean công khai hasFloatList ()
.tensorflow.CollectionDef.FloatList float_list = 4;
boolean công khai hasInt64List ()
.tensorflow.CollectionDef.Int64List int64_list = 3;
boolean công khai hasNodeList ()
.tensorflow.CollectionDef.NodeList node_list = 1;
mã băm int công khai ()
boolean cuối cùng công khai được khởi tạo ()
public static CollectionDef ParseDelimitedFrom (Đầu vào InputStream, com.google.protobuf.ExtensionRegistryLite ExtensionRegistry)
Ném
| IOException |
|---|
public static CollectionDef phân tích từ (dữ liệu ByteBuffer)
Ném
| Giao thức đệm ngoại lệ không hợp lệ |
|---|
public static CollectionDef phân tích cú phápFrom (đầu vào com.google.protobuf.CodedInputStream, com.google.protobuf.ExtensionRegistryLite ExtensionRegistry)
Ném
| IOException |
|---|
public static CollectionDef phân tích cú phápFrom (Dữ liệu ByteBuffer, com.google.protobuf.ExtensionRegistryLite ExtensionRegistry)
Ném
| Giao thức đệm ngoại lệ không hợp lệ |
|---|
public static CollectionDef phân tích từ (đầu vào com.google.protobuf.CodedInputStream)
Ném
| IOException |
|---|
public static CollectionDef phân tích cú phápFrom (dữ liệu byte[], com.google.protobuf.ExtensionRegistryLite ExtensionRegistry)
Ném
| Giao thức đệm ngoại lệ không hợp lệ |
|---|
public static CollectionDef phân tích từ (dữ liệu com.google.protobuf.ByteString)
Ném
| Giao thức đệm ngoại lệ không hợp lệ |
|---|
public static CollectionDef phân tích từ (đầu vào InputStream, com.google.protobuf.ExtensionRegistryLite ExtensionRegistry)
Ném
| IOException |
|---|
public static CollectionDef phân tích cú phápFrom (dữ liệu com.google.protobuf.ByteString, com.google.protobuf.ExtensionRegistryLite ExtensionRegistry)
Ném
| Giao thức đệm ngoại lệ không hợp lệ |
|---|
công cộng tĩnh trình phân tích cú pháp ()
public void writeTo (đầu ra com.google.protobuf.CodedOutputStream)
Ném
| IOException |
|---|