This document outlines how to express each TensorFlow operation on top of loco
CAUTION All the python examples below are written in Python 3 with TensorFlow v1.13.
DISCLAIMER loco does not support named values, but all the below loco examples assign “name” to each value to make it easy to read.
Placeholder
Placeholder in TensorFlow corresponds to Pull in loco.
Python:
import tensorflow as tf
input = tf.placeholder(dtype=tf.float32, shape=[3, 4], name='input')
print(tf.get_default_graph().as_graph_def())
API reference: tf.placeholder
TensorFlow
node {
name: "input"
op: "Placeholder"
attr {
key: "dtype"
value { type: DT_FLOAT }
}
attr {
key: "shape"
value {
shape {
dim { size: 3 }
dim { size: 4 }
}
}
}
}
loco:
%input = Pull(dtype: FLOAT32, shape: [3, 4])
Push(%input)
Identity
Identity in TensorFlow corresponds to Forward in loco.
Python:
import tensorflow as tf
input = tf.placeholder(dtype=tf.float32, shape=[3, 4])
ident = tf.identity(input)
print(tf.get_default_graph().as_graph_def())
API reference: tf.identity
TensorFlow:
node {
name: "Placeholder"
op: "Placeholder"
attr {
key: "dtype"
value { type: DT_FLOAT }
}
attr {
key: "shape"
value {
shape {
dim { size: 3 }
dim { size: 4 }
}
}
}
}
node {
name: "Identity"
op: "Identity"
input: "Placeholder"
attr {
key: "T"
value { type: DT_FLOAT }
}
}
loco:
%input = Pull(dtype: FLOAT32, shape: [3, 4])
%ident = Forward(%input)
Push(%ident)
Const
Const in TensorFlow corresponds to ConstGen in loco.
Python:
import tensorflow as tf
constant = tf.constant(value=[1.0], dtype=tf.float32, shape=[3, 4])
tf.get_default_graph().as_graph_def()
API reference: tf.constant
TensorFlow:
node {
name: "Const"
op: "Const"
attr {
key: "dtype"
value { type: DT_FLOAT }
}
attr {
key: "value"
value {
tensor {
dtype: DT_FLOAT
tensor_shape {
dim { size: 3 }
dim { size: 4 }
}
float_val: 1.0
}
}
}
}
loco:
%constant = ConstGen(dtype: FLOAT32, shape: [3, 4], data: ...);
Push(%constant)