make_attribute {onnx} | R Documentation |
Make Different Types of Protos
Description
This includes AttributeProto, GraphProto, NodeProto, TensorProto, TensorValueInfoProto, etc.
Usage
make_attribute(key, value, doc_string = NULL)
make_graph(nodes, name, inputs, outputs, initializer = NULL, doc_string = NULL)
make_node(op_type, inputs, outputs, name = NULL, doc_string = NULL)
make_tensor(name, data_type, dims, vals, raw = FALSE)
make_tensor_value_info(name, elem_type, shape, doc_string = "")
Arguments
key |
The key |
value |
The value |
doc_string |
The doc_string |
nodes |
The nodes |
name |
The name |
inputs |
The inputs |
outputs |
The outputs |
initializer |
The initializer |
op_type |
The op type |
data_type |
The data type |
dims |
The dimensions |
vals |
The values |
raw |
If this is |
elem_type |
The element type, e.g. |
shape |
The shape |
Examples
## Not run:
library(onnx)
# Define a node protobuf and check whether it's valid
node_def <- make_node("Relu", list("X"), list("Y"))
check(node_def)
# Define an attribute protobuf and check whether it's valid
attr_def <- make_attribute("this_is_an_int", 123L)
check(attr_def)
# Define a graph protobuf and check whether it's valid
graph_def <- make_graph(
nodes = list(
make_node("FC", list("X", "W1", "B1"), list("H1")),
make_node("Relu", list("H1"), list("R1")),
make_node("FC", list("R1", "W2", "B2"), list("Y"))
),
name = "MLP",
inputs = list(
make_tensor_value_info('X' , onnx$TensorProto$FLOAT, list(1L)),
make_tensor_value_info('W1', onnx$TensorProto$FLOAT, list(1L)),
make_tensor_value_info('B1', onnx$TensorProto$FLOAT, list(1L)),
make_tensor_value_info('W2', onnx$TensorProto$FLOAT, list(1L)),
make_tensor_value_info('B2', onnx$TensorProto$FLOAT, list(1L))
),
outputs = list(
make_tensor_value_info('Y', onnx$TensorProto$FLOAT, list(1L))
)
)
check(graph_def)
## End(Not run)
[Package onnx version 0.0.3 Index]