partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
iter_coords
Returns all the coordinate tuples from a geometry or feature.
folium/utilities.py
def iter_coords(obj): """ Returns all the coordinate tuples from a geometry or feature. """ if isinstance(obj, (tuple, list)): coords = obj elif 'features' in obj: coords = [geom['geometry']['coordinates'] for geom in obj['features']] elif 'geometry' in obj: coords = obj...
def iter_coords(obj): """ Returns all the coordinate tuples from a geometry or feature. """ if isinstance(obj, (tuple, list)): coords = obj elif 'features' in obj: coords = [geom['geometry']['coordinates'] for geom in obj['features']] elif 'geometry' in obj: coords = obj...
[ "Returns", "all", "the", "coordinate", "tuples", "from", "a", "geometry", "or", "feature", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L321-L340
[ "def", "iter_coords", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "(", "tuple", ",", "list", ")", ")", ":", "coords", "=", "obj", "elif", "'features'", "in", "obj", ":", "coords", "=", "[", "geom", "[", "'geometry'", "]", "[", "'coor...
8595240517135d1637ca4cf7cc624045f1d911b3
train
_locations_mirror
Mirrors the points in a list-of-list-of-...-of-list-of-points. For example: >>> _locations_mirror([[[1, 2], [3, 4]], [5, 6], [7, 8]]) [[[2, 1], [4, 3]], [6, 5], [8, 7]]
folium/utilities.py
def _locations_mirror(x): """ Mirrors the points in a list-of-list-of-...-of-list-of-points. For example: >>> _locations_mirror([[[1, 2], [3, 4]], [5, 6], [7, 8]]) [[[2, 1], [4, 3]], [6, 5], [8, 7]] """ if hasattr(x, '__iter__'): if hasattr(x[0], '__iter__'): return list...
def _locations_mirror(x): """ Mirrors the points in a list-of-list-of-...-of-list-of-points. For example: >>> _locations_mirror([[[1, 2], [3, 4]], [5, 6], [7, 8]]) [[[2, 1], [4, 3]], [6, 5], [8, 7]] """ if hasattr(x, '__iter__'): if hasattr(x[0], '__iter__'): return list...
[ "Mirrors", "the", "points", "in", "a", "list", "-", "of", "-", "list", "-", "of", "-", "...", "-", "of", "-", "list", "-", "of", "-", "points", ".", "For", "example", ":", ">>>", "_locations_mirror", "(", "[[[", "1", "2", "]", "[", "3", "4", "]...
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L343-L357
[ "def", "_locations_mirror", "(", "x", ")", ":", "if", "hasattr", "(", "x", ",", "'__iter__'", ")", ":", "if", "hasattr", "(", "x", "[", "0", "]", ",", "'__iter__'", ")", ":", "return", "list", "(", "map", "(", "_locations_mirror", ",", "x", ")", ")...
8595240517135d1637ca4cf7cc624045f1d911b3
train
get_bounds
Computes the bounds of the object in the form [[lat_min, lon_min], [lat_max, lon_max]]
folium/utilities.py
def get_bounds(locations, lonlat=False): """ Computes the bounds of the object in the form [[lat_min, lon_min], [lat_max, lon_max]] """ bounds = [[None, None], [None, None]] for point in iter_coords(locations): bounds = [ [ none_min(bounds[0][0], point[0]), ...
def get_bounds(locations, lonlat=False): """ Computes the bounds of the object in the form [[lat_min, lon_min], [lat_max, lon_max]] """ bounds = [[None, None], [None, None]] for point in iter_coords(locations): bounds = [ [ none_min(bounds[0][0], point[0]), ...
[ "Computes", "the", "bounds", "of", "the", "object", "in", "the", "form", "[[", "lat_min", "lon_min", "]", "[", "lat_max", "lon_max", "]]" ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L360-L380
[ "def", "get_bounds", "(", "locations", ",", "lonlat", "=", "False", ")", ":", "bounds", "=", "[", "[", "None", ",", "None", "]", ",", "[", "None", ",", "None", "]", "]", "for", "point", "in", "iter_coords", "(", "locations", ")", ":", "bounds", "="...
8595240517135d1637ca4cf7cc624045f1d911b3
train
camelize
Convert a python_style_variable_name to lowerCamelCase. Examples -------- >>> camelize('variable_name') 'variableName' >>> camelize('variableName') 'variableName'
folium/utilities.py
def camelize(key): """Convert a python_style_variable_name to lowerCamelCase. Examples -------- >>> camelize('variable_name') 'variableName' >>> camelize('variableName') 'variableName' """ return ''.join(x.capitalize() if i > 0 else x for i, x in enumerate(key.spl...
def camelize(key): """Convert a python_style_variable_name to lowerCamelCase. Examples -------- >>> camelize('variable_name') 'variableName' >>> camelize('variableName') 'variableName' """ return ''.join(x.capitalize() if i > 0 else x for i, x in enumerate(key.spl...
[ "Convert", "a", "python_style_variable_name", "to", "lowerCamelCase", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L383-L394
[ "def", "camelize", "(", "key", ")", ":", "return", "''", ".", "join", "(", "x", ".", "capitalize", "(", ")", "if", "i", ">", "0", "else", "x", "for", "i", ",", "x", "in", "enumerate", "(", "key", ".", "split", "(", "'_'", ")", ")", ")" ]
8595240517135d1637ca4cf7cc624045f1d911b3
train
normalize
Return the input string without non-functional spaces or newlines.
folium/utilities.py
def normalize(rendered): """Return the input string without non-functional spaces or newlines.""" out = ''.join([line.strip() for line in rendered.splitlines() if line.strip()]) out = out.replace(', ', ',') return out
def normalize(rendered): """Return the input string without non-functional spaces or newlines.""" out = ''.join([line.strip() for line in rendered.splitlines() if line.strip()]) out = out.replace(', ', ',') return out
[ "Return", "the", "input", "string", "without", "non", "-", "functional", "spaces", "or", "newlines", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L440-L446
[ "def", "normalize", "(", "rendered", ")", ":", "out", "=", "''", ".", "join", "(", "[", "line", ".", "strip", "(", ")", "for", "line", "in", "rendered", ".", "splitlines", "(", ")", "if", "line", ".", "strip", "(", ")", "]", ")", "out", "=", "o...
8595240517135d1637ca4cf7cc624045f1d911b3
train
_tmp_html
Yields the path of a temporary HTML file containing data.
folium/utilities.py
def _tmp_html(data): """Yields the path of a temporary HTML file containing data.""" filepath = '' try: fid, filepath = tempfile.mkstemp(suffix='.html', prefix='folium_') os.write(fid, data.encode('utf8')) os.close(fid) yield filepath finally: if os.path.isfile(fi...
def _tmp_html(data): """Yields the path of a temporary HTML file containing data.""" filepath = '' try: fid, filepath = tempfile.mkstemp(suffix='.html', prefix='folium_') os.write(fid, data.encode('utf8')) os.close(fid) yield filepath finally: if os.path.isfile(fi...
[ "Yields", "the", "path", "of", "a", "temporary", "HTML", "file", "containing", "data", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L450-L460
[ "def", "_tmp_html", "(", "data", ")", ":", "filepath", "=", "''", "try", ":", "fid", ",", "filepath", "=", "tempfile", ".", "mkstemp", "(", "suffix", "=", "'.html'", ",", "prefix", "=", "'folium_'", ")", "os", ".", "write", "(", "fid", ",", "data", ...
8595240517135d1637ca4cf7cc624045f1d911b3
train
deep_copy
Return a recursive deep-copy of item where each copy has a new ID.
folium/utilities.py
def deep_copy(item_original): """Return a recursive deep-copy of item where each copy has a new ID.""" item = copy.copy(item_original) item._id = uuid.uuid4().hex if hasattr(item, '_children') and len(item._children) > 0: children_new = collections.OrderedDict() for subitem_original in i...
def deep_copy(item_original): """Return a recursive deep-copy of item where each copy has a new ID.""" item = copy.copy(item_original) item._id = uuid.uuid4().hex if hasattr(item, '_children') and len(item._children) > 0: children_new = collections.OrderedDict() for subitem_original in i...
[ "Return", "a", "recursive", "deep", "-", "copy", "of", "item", "where", "each", "copy", "has", "a", "new", "ID", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L463-L474
[ "def", "deep_copy", "(", "item_original", ")", ":", "item", "=", "copy", ".", "copy", "(", "item_original", ")", "item", ".", "_id", "=", "uuid", ".", "uuid4", "(", ")", ".", "hex", "if", "hasattr", "(", "item", ",", "'_children'", ")", "and", "len",...
8595240517135d1637ca4cf7cc624045f1d911b3
train
get_obj_in_upper_tree
Return the first object in the parent tree of class `cls`.
folium/utilities.py
def get_obj_in_upper_tree(element, cls): """Return the first object in the parent tree of class `cls`.""" if not hasattr(element, '_parent'): raise ValueError('The top of the tree was reached without finding a {}' .format(cls)) parent = element._parent if not isinstance(...
def get_obj_in_upper_tree(element, cls): """Return the first object in the parent tree of class `cls`.""" if not hasattr(element, '_parent'): raise ValueError('The top of the tree was reached without finding a {}' .format(cls)) parent = element._parent if not isinstance(...
[ "Return", "the", "first", "object", "in", "the", "parent", "tree", "of", "class", "cls", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L477-L485
[ "def", "get_obj_in_upper_tree", "(", "element", ",", "cls", ")", ":", "if", "not", "hasattr", "(", "element", ",", "'_parent'", ")", ":", "raise", "ValueError", "(", "'The top of the tree was reached without finding a {}'", ".", "format", "(", "cls", ")", ")", "...
8595240517135d1637ca4cf7cc624045f1d911b3
train
parse_options
Return a dict with lower-camelcase keys and non-None values..
folium/utilities.py
def parse_options(**kwargs): """Return a dict with lower-camelcase keys and non-None values..""" return {camelize(key): value for key, value in kwargs.items() if value is not None}
def parse_options(**kwargs): """Return a dict with lower-camelcase keys and non-None values..""" return {camelize(key): value for key, value in kwargs.items() if value is not None}
[ "Return", "a", "dict", "with", "lower", "-", "camelcase", "keys", "and", "non", "-", "None", "values", ".." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L488-L492
[ "def", "parse_options", "(", "*", "*", "kwargs", ")", ":", "return", "{", "camelize", "(", "key", ")", ":", "value", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", "if", "value", "is", "not", "None", "}" ]
8595240517135d1637ca4cf7cc624045f1d911b3
train
LayerControl.render
Renders the HTML representation of the element.
folium/map.py
def render(self, **kwargs): """Renders the HTML representation of the element.""" for item in self._parent._children.values(): if not isinstance(item, Layer) or not item.control: continue key = item.layer_name if not item.overlay: self....
def render(self, **kwargs): """Renders the HTML representation of the element.""" for item in self._parent._children.values(): if not isinstance(item, Layer) or not item.control: continue key = item.layer_name if not item.overlay: self....
[ "Renders", "the", "HTML", "representation", "of", "the", "element", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/map.py#L148-L162
[ "def", "render", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "item", "in", "self", ".", "_parent", ".", "_children", ".", "values", "(", ")", ":", "if", "not", "isinstance", "(", "item", ",", "Layer", ")", "or", "not", "item", ".", "co...
8595240517135d1637ca4cf7cc624045f1d911b3
train
Popup.render
Renders the HTML representation of the element.
folium/map.py
def render(self, **kwargs): """Renders the HTML representation of the element.""" for name, child in self._children.items(): child.render(**kwargs) figure = self.get_root() assert isinstance(figure, Figure), ('You cannot render this Element ' ...
def render(self, **kwargs): """Renders the HTML representation of the element.""" for name, child in self._children.items(): child.render(**kwargs) figure = self.get_root() assert isinstance(figure, Figure), ('You cannot render this Element ' ...
[ "Renders", "the", "HTML", "representation", "of", "the", "element", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/map.py#L354-L365
[ "def", "render", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "name", ",", "child", "in", "self", ".", "_children", ".", "items", "(", ")", ":", "child", ".", "render", "(", "*", "*", "kwargs", ")", "figure", "=", "self", ".", "get_root...
8595240517135d1637ca4cf7cc624045f1d911b3
train
Tooltip.parse_options
Validate the provided kwargs and return options as json string.
folium/map.py
def parse_options(self, kwargs): """Validate the provided kwargs and return options as json string.""" kwargs = {camelize(key): value for key, value in kwargs.items()} for key in kwargs.keys(): assert key in self.valid_options, ( 'The option {} is not in the available...
def parse_options(self, kwargs): """Validate the provided kwargs and return options as json string.""" kwargs = {camelize(key): value for key, value in kwargs.items()} for key in kwargs.keys(): assert key in self.valid_options, ( 'The option {} is not in the available...
[ "Validate", "the", "provided", "kwargs", "and", "return", "options", "as", "json", "string", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/map.py#L424-L436
[ "def", "parse_options", "(", "self", ",", "kwargs", ")", ":", "kwargs", "=", "{", "camelize", "(", "key", ")", ":", "value", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", "}", "for", "key", "in", "kwargs", ".", "keys", "(", ...
8595240517135d1637ca4cf7cc624045f1d911b3
train
Map._repr_html_
Displays the HTML Map in a Jupyter notebook.
folium/folium.py
def _repr_html_(self, **kwargs): """Displays the HTML Map in a Jupyter notebook.""" if self._parent is None: self.add_to(Figure()) out = self._parent._repr_html_(**kwargs) self._parent = None else: out = self._parent._repr_html_(**kwargs) r...
def _repr_html_(self, **kwargs): """Displays the HTML Map in a Jupyter notebook.""" if self._parent is None: self.add_to(Figure()) out = self._parent._repr_html_(**kwargs) self._parent = None else: out = self._parent._repr_html_(**kwargs) r...
[ "Displays", "the", "HTML", "Map", "in", "a", "Jupyter", "notebook", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/folium.py#L288-L296
[ "def", "_repr_html_", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_parent", "is", "None", ":", "self", ".", "add_to", "(", "Figure", "(", ")", ")", "out", "=", "self", ".", "_parent", ".", "_repr_html_", "(", "*", "*", "kw...
8595240517135d1637ca4cf7cc624045f1d911b3
train
Map._to_png
Export the HTML to byte representation of a PNG image. Uses selenium to render the HTML and record a PNG. You may need to adjust the `delay` time keyword argument if maps render without data or tiles. Examples -------- >>> m._to_png() >>> m._to_png(time=10) # Wait 10 s...
folium/folium.py
def _to_png(self, delay=3): """Export the HTML to byte representation of a PNG image. Uses selenium to render the HTML and record a PNG. You may need to adjust the `delay` time keyword argument if maps render without data or tiles. Examples -------- >>> m._to_png() ...
def _to_png(self, delay=3): """Export the HTML to byte representation of a PNG image. Uses selenium to render the HTML and record a PNG. You may need to adjust the `delay` time keyword argument if maps render without data or tiles. Examples -------- >>> m._to_png() ...
[ "Export", "the", "HTML", "to", "byte", "representation", "of", "a", "PNG", "image", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/folium.py#L298-L326
[ "def", "_to_png", "(", "self", ",", "delay", "=", "3", ")", ":", "if", "self", ".", "_png_image", "is", "None", ":", "from", "selenium", "import", "webdriver", "options", "=", "webdriver", ".", "firefox", ".", "options", ".", "Options", "(", ")", "opti...
8595240517135d1637ca4cf7cc624045f1d911b3
train
Map.render
Renders the HTML representation of the element.
folium/folium.py
def render(self, **kwargs): """Renders the HTML representation of the element.""" figure = self.get_root() assert isinstance(figure, Figure), ('You cannot render this Element ' 'if it is not in a Figure.') # Set global switches figure....
def render(self, **kwargs): """Renders the HTML representation of the element.""" figure = self.get_root() assert isinstance(figure, Figure), ('You cannot render this Element ' 'if it is not in a Figure.') # Set global switches figure....
[ "Renders", "the", "HTML", "representation", "of", "the", "element", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/folium.py#L336-L372
[ "def", "render", "(", "self", ",", "*", "*", "kwargs", ")", ":", "figure", "=", "self", ".", "get_root", "(", ")", "assert", "isinstance", "(", "figure", ",", "Figure", ")", ",", "(", "'You cannot render this Element '", "'if it is not in a Figure.'", ")", "...
8595240517135d1637ca4cf7cc624045f1d911b3
train
Map.fit_bounds
Fit the map to contain a bounding box with the maximum zoom level possible. Parameters ---------- bounds: list of (latitude, longitude) points Bounding box specified as two points [southwest, northeast] padding_top_left: (x, y) point, default None Padding...
folium/folium.py
def fit_bounds(self, bounds, padding_top_left=None, padding_bottom_right=None, padding=None, max_zoom=None): """Fit the map to contain a bounding box with the maximum zoom level possible. Parameters ---------- bounds: list of (latitude, longitude) points ...
def fit_bounds(self, bounds, padding_top_left=None, padding_bottom_right=None, padding=None, max_zoom=None): """Fit the map to contain a bounding box with the maximum zoom level possible. Parameters ---------- bounds: list of (latitude, longitude) points ...
[ "Fit", "the", "map", "to", "contain", "a", "bounding", "box", "with", "the", "maximum", "zoom", "level", "possible", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/folium.py#L374-L406
[ "def", "fit_bounds", "(", "self", ",", "bounds", ",", "padding_top_left", "=", "None", ",", "padding_bottom_right", "=", "None", ",", "padding", "=", "None", ",", "max_zoom", "=", "None", ")", ":", "self", ".", "add_child", "(", "FitBounds", "(", "bounds",...
8595240517135d1637ca4cf7cc624045f1d911b3
train
Map.choropleth
Call the Choropleth class with the same arguments. This method may be deleted after a year from now (Nov 2018).
folium/folium.py
def choropleth(self, *args, **kwargs): """Call the Choropleth class with the same arguments. This method may be deleted after a year from now (Nov 2018). """ warnings.warn( 'The choropleth method has been deprecated. Instead use the new ' 'Choropleth class, whic...
def choropleth(self, *args, **kwargs): """Call the Choropleth class with the same arguments. This method may be deleted after a year from now (Nov 2018). """ warnings.warn( 'The choropleth method has been deprecated. Instead use the new ' 'Choropleth class, whic...
[ "Call", "the", "Choropleth", "class", "with", "the", "same", "arguments", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/folium.py#L408-L420
[ "def", "choropleth", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "'The choropleth method has been deprecated. Instead use the new '", "'Choropleth class, which has the same arguments. See the example '", "'notebook \\'GeoJSON...
8595240517135d1637ca4cf7cc624045f1d911b3
train
TimestampedGeoJson._get_self_bounds
Computes the bounds of the object itself (not including it's children) in the form [[lat_min, lon_min], [lat_max, lon_max]].
folium/plugins/timestamped_geo_json.py
def _get_self_bounds(self): """ Computes the bounds of the object itself (not including it's children) in the form [[lat_min, lon_min], [lat_max, lon_max]]. """ if not self.embed: raise ValueError('Cannot compute bounds of non-embedded GeoJSON.') data = json...
def _get_self_bounds(self): """ Computes the bounds of the object itself (not including it's children) in the form [[lat_min, lon_min], [lat_max, lon_max]]. """ if not self.embed: raise ValueError('Cannot compute bounds of non-embedded GeoJSON.') data = json...
[ "Computes", "the", "bounds", "of", "the", "object", "itself", "(", "not", "including", "it", "s", "children", ")", "in", "the", "form", "[[", "lat_min", "lon_min", "]", "[", "lat_max", "lon_max", "]]", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/plugins/timestamped_geo_json.py#L213-L243
[ "def", "_get_self_bounds", "(", "self", ")", ":", "if", "not", "self", ".", "embed", ":", "raise", "ValueError", "(", "'Cannot compute bounds of non-embedded GeoJSON.'", ")", "data", "=", "json", ".", "loads", "(", "self", ".", "data", ")", "if", "'features'",...
8595240517135d1637ca4cf7cc624045f1d911b3
train
DualMap.add_child
Add object `child` to the first map and store it for the second.
folium/plugins/dual_map.py
def add_child(self, child, name=None, index=None): """Add object `child` to the first map and store it for the second.""" self.m1.add_child(child, name, index) if index is None: index = len(self.m2._children) self.children_for_m2.append((child, name, index))
def add_child(self, child, name=None, index=None): """Add object `child` to the first map and store it for the second.""" self.m1.add_child(child, name, index) if index is None: index = len(self.m2._children) self.children_for_m2.append((child, name, index))
[ "Add", "object", "child", "to", "the", "first", "map", "and", "store", "it", "for", "the", "second", "." ]
python-visualization/folium
python
https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/plugins/dual_map.py#L83-L88
[ "def", "add_child", "(", "self", ",", "child", ",", "name", "=", "None", ",", "index", "=", "None", ")", ":", "self", ".", "m1", ".", "add_child", "(", "child", ",", "name", ",", "index", ")", "if", "index", "is", "None", ":", "index", "=", "len"...
8595240517135d1637ca4cf7cc624045f1d911b3
train
start
Create a new multiprocess.Manager (or return existing one). Args: :authkey: string authorization key :queues: *INTERNAL_USE* :mode: 'local' indicates that the manager will only be accessible from the same host, otherwise remotely accessible. Returns: A TFManager instance, which is also cached in l...
tensorflowonspark/TFManager.py
def start(authkey, queues, mode='local'): """Create a new multiprocess.Manager (or return existing one). Args: :authkey: string authorization key :queues: *INTERNAL_USE* :mode: 'local' indicates that the manager will only be accessible from the same host, otherwise remotely accessible. Returns: ...
def start(authkey, queues, mode='local'): """Create a new multiprocess.Manager (or return existing one). Args: :authkey: string authorization key :queues: *INTERNAL_USE* :mode: 'local' indicates that the manager will only be accessible from the same host, otherwise remotely accessible. Returns: ...
[ "Create", "a", "new", "multiprocess", ".", "Manager", "(", "or", "return", "existing", "one", ")", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFManager.py#L40-L65
[ "def", "start", "(", "authkey", ",", "queues", ",", "mode", "=", "'local'", ")", ":", "global", "mgr", ",", "qdict", ",", "kdict", "qdict", ".", "clear", "(", ")", "kdict", ".", "clear", "(", ")", "for", "q", "in", "queues", ":", "qdict", "[", "q...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
connect
Connect to a multiprocess.Manager. Args: :address: unique address to the TFManager, either a unique connection string for 'local', or a (host, port) tuple for remote. :authkey: string authorization key Returns: A TFManager instance referencing the remote TFManager at the supplied address.
tensorflowonspark/TFManager.py
def connect(address, authkey): """Connect to a multiprocess.Manager. Args: :address: unique address to the TFManager, either a unique connection string for 'local', or a (host, port) tuple for remote. :authkey: string authorization key Returns: A TFManager instance referencing the remote TFManager a...
def connect(address, authkey): """Connect to a multiprocess.Manager. Args: :address: unique address to the TFManager, either a unique connection string for 'local', or a (host, port) tuple for remote. :authkey: string authorization key Returns: A TFManager instance referencing the remote TFManager a...
[ "Connect", "to", "a", "multiprocess", ".", "Manager", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFManager.py#L68-L83
[ "def", "connect", "(", "address", ",", "authkey", ")", ":", "TFManager", ".", "register", "(", "'get_queue'", ")", "TFManager", ".", "register", "(", "'get'", ")", "TFManager", ".", "register", "(", "'set'", ")", "m", "=", "TFManager", "(", "address", ",...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
ProcessXMLAnnotation
Process a single XML file containing a bounding box.
examples/imagenet/inception/data/process_bounding_boxes.py
def ProcessXMLAnnotation(xml_file): """Process a single XML file containing a bounding box.""" # pylint: disable=broad-except try: tree = ET.parse(xml_file) except Exception: print('Failed to parse: ' + xml_file, file=sys.stderr) return None # pylint: enable=broad-except root = tree.getroot() ...
def ProcessXMLAnnotation(xml_file): """Process a single XML file containing a bounding box.""" # pylint: disable=broad-except try: tree = ET.parse(xml_file) except Exception: print('Failed to parse: ' + xml_file, file=sys.stderr) return None # pylint: enable=broad-except root = tree.getroot() ...
[ "Process", "a", "single", "XML", "file", "containing", "a", "bounding", "box", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/process_bounding_boxes.py#L119-L168
[ "def", "ProcessXMLAnnotation", "(", "xml_file", ")", ":", "# pylint: disable=broad-except", "try", ":", "tree", "=", "ET", ".", "parse", "(", "xml_file", ")", "except", "Exception", ":", "print", "(", "'Failed to parse: '", "+", "xml_file", ",", "file", "=", "...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
Dataset.data_files
Returns a python list of all (sharded) data subset files. Returns: python list of all (sharded) data set files. Raises: ValueError: if there are not data_files matching the subset.
examples/imagenet/inception/dataset.py
def data_files(self): """Returns a python list of all (sharded) data subset files. Returns: python list of all (sharded) data set files. Raises: ValueError: if there are not data_files matching the subset. """ tf_record_pattern = os.path.join(FLAGS.data_dir, '%s-*' % self.subset) da...
def data_files(self): """Returns a python list of all (sharded) data subset files. Returns: python list of all (sharded) data set files. Raises: ValueError: if there are not data_files matching the subset. """ tf_record_pattern = os.path.join(FLAGS.data_dir, '%s-*' % self.subset) da...
[ "Returns", "a", "python", "list", "of", "all", "(", "sharded", ")", "data", "subset", "files", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/dataset.py#L76-L93
[ "def", "data_files", "(", "self", ")", ":", "tf_record_pattern", "=", "os", ".", "path", ".", "join", "(", "FLAGS", ".", "data_dir", ",", "'%s-*'", "%", "self", ".", "subset", ")", "data_files", "=", "tf", ".", "gfile", ".", "Glob", "(", "tf_record_pat...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_activation_summary
Helper to create summaries for activations. Creates a summary that provides a histogram of activations. Creates a summary that measures the sparsity of activations. Args: x: Tensor Returns: nothing
examples/cifar10/cifar10.py
def _activation_summary(x): """Helper to create summaries for activations. Creates a summary that provides a histogram of activations. Creates a summary that measures the sparsity of activations. Args: x: Tensor Returns: nothing """ # Remove 'tower_[0-9]/' from the name in case this is a multi-G...
def _activation_summary(x): """Helper to create summaries for activations. Creates a summary that provides a histogram of activations. Creates a summary that measures the sparsity of activations. Args: x: Tensor Returns: nothing """ # Remove 'tower_[0-9]/' from the name in case this is a multi-G...
[ "Helper", "to", "create", "summaries", "for", "activations", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10.py#L79-L95
[ "def", "_activation_summary", "(", "x", ")", ":", "# Remove 'tower_[0-9]/' from the name in case this is a multi-GPU training", "# session. This helps the clarity of presentation on tensorboard.", "tensor_name", "=", "re", ".", "sub", "(", "'%s_[0-9]*/'", "%", "TOWER_NAME", ",", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_variable_on_cpu
Helper to create a Variable stored on CPU memory. Args: name: name of the variable shape: list of ints initializer: initializer for Variable Returns: Variable Tensor
examples/cifar10/cifar10.py
def _variable_on_cpu(name, shape, initializer): """Helper to create a Variable stored on CPU memory. Args: name: name of the variable shape: list of ints initializer: initializer for Variable Returns: Variable Tensor """ with tf.device('/cpu:0'): dtype = tf.float16 if FLAGS.use_fp16 else...
def _variable_on_cpu(name, shape, initializer): """Helper to create a Variable stored on CPU memory. Args: name: name of the variable shape: list of ints initializer: initializer for Variable Returns: Variable Tensor """ with tf.device('/cpu:0'): dtype = tf.float16 if FLAGS.use_fp16 else...
[ "Helper", "to", "create", "a", "Variable", "stored", "on", "CPU", "memory", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10.py#L98-L112
[ "def", "_variable_on_cpu", "(", "name", ",", "shape", ",", "initializer", ")", ":", "with", "tf", ".", "device", "(", "'/cpu:0'", ")", ":", "dtype", "=", "tf", ".", "float16", "if", "FLAGS", ".", "use_fp16", "else", "tf", ".", "float32", "var", "=", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_variable_with_weight_decay
Helper to create an initialized Variable with weight decay. Note that the Variable is initialized with a truncated normal distribution. A weight decay is added only if one is specified. Args: name: name of the variable shape: list of ints stddev: standard deviation of a truncated Gaussian wd: ad...
examples/cifar10/cifar10.py
def _variable_with_weight_decay(name, shape, stddev, wd): """Helper to create an initialized Variable with weight decay. Note that the Variable is initialized with a truncated normal distribution. A weight decay is added only if one is specified. Args: name: name of the variable shape: list of ints ...
def _variable_with_weight_decay(name, shape, stddev, wd): """Helper to create an initialized Variable with weight decay. Note that the Variable is initialized with a truncated normal distribution. A weight decay is added only if one is specified. Args: name: name of the variable shape: list of ints ...
[ "Helper", "to", "create", "an", "initialized", "Variable", "with", "weight", "decay", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10.py#L115-L139
[ "def", "_variable_with_weight_decay", "(", "name", ",", "shape", ",", "stddev", ",", "wd", ")", ":", "dtype", "=", "tf", ".", "float16", "if", "FLAGS", ".", "use_fp16", "else", "tf", ".", "float32", "var", "=", "_variable_on_cpu", "(", "name", ",", "shap...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
distorted_inputs
Construct distorted input for CIFAR training using the Reader ops. Returns: images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size. labels: Labels. 1D tensor of [batch_size] size. Raises: ValueError: If no data_dir
examples/cifar10/cifar10.py
def distorted_inputs(): """Construct distorted input for CIFAR training using the Reader ops. Returns: images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size. labels: Labels. 1D tensor of [batch_size] size. Raises: ValueError: If no data_dir """ if not FLAGS.data_dir: rais...
def distorted_inputs(): """Construct distorted input for CIFAR training using the Reader ops. Returns: images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size. labels: Labels. 1D tensor of [batch_size] size. Raises: ValueError: If no data_dir """ if not FLAGS.data_dir: rais...
[ "Construct", "distorted", "input", "for", "CIFAR", "training", "using", "the", "Reader", "ops", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10.py#L142-L160
[ "def", "distorted_inputs", "(", ")", ":", "if", "not", "FLAGS", ".", "data_dir", ":", "raise", "ValueError", "(", "'Please supply a data_dir'", ")", "data_dir", "=", "os", ".", "path", ".", "join", "(", "FLAGS", ".", "data_dir", ",", "'cifar-10-batches-bin'", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
inference
Build the CIFAR-10 model. Args: images: Images returned from distorted_inputs() or inputs(). Returns: Logits.
examples/cifar10/cifar10.py
def inference(images): """Build the CIFAR-10 model. Args: images: Images returned from distorted_inputs() or inputs(). Returns: Logits. """ # We instantiate all variables using tf.get_variable() instead of # tf.Variable() in order to share variables across multiple GPU training runs. # If we onl...
def inference(images): """Build the CIFAR-10 model. Args: images: Images returned from distorted_inputs() or inputs(). Returns: Logits. """ # We instantiate all variables using tf.get_variable() instead of # tf.Variable() in order to share variables across multiple GPU training runs. # If we onl...
[ "Build", "the", "CIFAR", "-", "10", "model", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10.py#L188-L271
[ "def", "inference", "(", "images", ")", ":", "# We instantiate all variables using tf.get_variable() instead of", "# tf.Variable() in order to share variables across multiple GPU training runs.", "# If we only ran this model on a single GPU, we could simplify this function", "# by replacing all in...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
loss
Add L2Loss to all the trainable variables. Add summary for "Loss" and "Loss/avg". Args: logits: Logits from inference(). labels: Labels from distorted_inputs or inputs(). 1-D tensor of shape [batch_size] Returns: Loss tensor of type float.
examples/cifar10/cifar10.py
def loss(logits, labels): """Add L2Loss to all the trainable variables. Add summary for "Loss" and "Loss/avg". Args: logits: Logits from inference(). labels: Labels from distorted_inputs or inputs(). 1-D tensor of shape [batch_size] Returns: Loss tensor of type float. """ # Calcula...
def loss(logits, labels): """Add L2Loss to all the trainable variables. Add summary for "Loss" and "Loss/avg". Args: logits: Logits from inference(). labels: Labels from distorted_inputs or inputs(). 1-D tensor of shape [batch_size] Returns: Loss tensor of type float. """ # Calcula...
[ "Add", "L2Loss", "to", "all", "the", "trainable", "variables", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10.py#L274-L295
[ "def", "loss", "(", "logits", ",", "labels", ")", ":", "# Calculate the average cross entropy loss across the batch.", "labels", "=", "tf", ".", "cast", "(", "labels", ",", "tf", ".", "int64", ")", "cross_entropy", "=", "tf", ".", "nn", ".", "sparse_softmax_cros...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_add_loss_summaries
Add summaries for losses in CIFAR-10 model. Generates moving average for all losses and associated summaries for visualizing the performance of the network. Args: total_loss: Total loss from loss(). Returns: loss_averages_op: op for generating moving averages of losses.
examples/cifar10/cifar10.py
def _add_loss_summaries(total_loss): """Add summaries for losses in CIFAR-10 model. Generates moving average for all losses and associated summaries for visualizing the performance of the network. Args: total_loss: Total loss from loss(). Returns: loss_averages_op: op for generating moving averages ...
def _add_loss_summaries(total_loss): """Add summaries for losses in CIFAR-10 model. Generates moving average for all losses and associated summaries for visualizing the performance of the network. Args: total_loss: Total loss from loss(). Returns: loss_averages_op: op for generating moving averages ...
[ "Add", "summaries", "for", "losses", "in", "CIFAR", "-", "10", "model", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10.py#L298-L322
[ "def", "_add_loss_summaries", "(", "total_loss", ")", ":", "# Compute the moving average of all individual losses and the total loss.", "loss_averages", "=", "tf", ".", "train", ".", "ExponentialMovingAverage", "(", "0.9", ",", "name", "=", "'avg'", ")", "losses", "=", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
train
Train CIFAR-10 model. Create an optimizer and apply to all trainable variables. Add moving average for all trainable variables. Args: total_loss: Total loss from loss(). global_step: Integer Variable counting the number of training steps processed. Returns: train_op: op for training.
examples/cifar10/cifar10.py
def train(total_loss, global_step): """Train CIFAR-10 model. Create an optimizer and apply to all trainable variables. Add moving average for all trainable variables. Args: total_loss: Total loss from loss(). global_step: Integer Variable counting the number of training steps processed. Return...
def train(total_loss, global_step): """Train CIFAR-10 model. Create an optimizer and apply to all trainable variables. Add moving average for all trainable variables. Args: total_loss: Total loss from loss(). global_step: Integer Variable counting the number of training steps processed. Return...
[ "Train", "CIFAR", "-", "10", "model", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10.py#L325-L378
[ "def", "train", "(", "total_loss", ",", "global_step", ")", ":", "# Variables that affect learning rate.", "num_batches_per_epoch", "=", "NUM_EXAMPLES_PER_EPOCH_FOR_TRAIN", "/", "FLAGS", ".", "batch_size", "decay_steps", "=", "int", "(", "num_batches_per_epoch", "*", "NUM...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
add_variable
Adds a variable to the MODEL_VARIABLES collection. Optionally it will add the variable to the VARIABLES_TO_RESTORE collection. Args: var: a variable. restore: whether the variable should be added to the VARIABLES_TO_RESTORE collection.
examples/imagenet/inception/slim/variables.py
def add_variable(var, restore=True): """Adds a variable to the MODEL_VARIABLES collection. Optionally it will add the variable to the VARIABLES_TO_RESTORE collection. Args: var: a variable. restore: whether the variable should be added to the VARIABLES_TO_RESTORE collection. """ collections...
def add_variable(var, restore=True): """Adds a variable to the MODEL_VARIABLES collection. Optionally it will add the variable to the VARIABLES_TO_RESTORE collection. Args: var: a variable. restore: whether the variable should be added to the VARIABLES_TO_RESTORE collection. """ collections...
[ "Adds", "a", "variable", "to", "the", "MODEL_VARIABLES", "collection", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/variables.py#L96-L111
[ "def", "add_variable", "(", "var", ",", "restore", "=", "True", ")", ":", "collections", "=", "[", "MODEL_VARIABLES", "]", "if", "restore", ":", "collections", ".", "append", "(", "VARIABLES_TO_RESTORE", ")", "for", "collection", "in", "collections", ":", "i...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
get_variables
Gets the list of variables, filtered by scope and/or suffix. Args: scope: an optional scope for filtering the variables to return. suffix: an optional suffix for filtering the variables to return. Returns: a copied list of variables with scope and suffix.
examples/imagenet/inception/slim/variables.py
def get_variables(scope=None, suffix=None): """Gets the list of variables, filtered by scope and/or suffix. Args: scope: an optional scope for filtering the variables to return. suffix: an optional suffix for filtering the variables to return. Returns: a copied list of variables with scope and suffi...
def get_variables(scope=None, suffix=None): """Gets the list of variables, filtered by scope and/or suffix. Args: scope: an optional scope for filtering the variables to return. suffix: an optional suffix for filtering the variables to return. Returns: a copied list of variables with scope and suffi...
[ "Gets", "the", "list", "of", "variables", "filtered", "by", "scope", "and", "/", "or", "suffix", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/variables.py#L114-L127
[ "def", "get_variables", "(", "scope", "=", "None", ",", "suffix", "=", "None", ")", ":", "candidates", "=", "tf", ".", "get_collection", "(", "MODEL_VARIABLES", ",", "scope", ")", "[", ":", "]", "if", "suffix", "is", "not", "None", ":", "candidates", "...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
get_unique_variable
Gets the variable uniquely identified by that name. Args: name: a name that uniquely identifies the variable. Returns: a tensorflow variable. Raises: ValueError: if no variable uniquely identified by the name exists.
examples/imagenet/inception/slim/variables.py
def get_unique_variable(name): """Gets the variable uniquely identified by that name. Args: name: a name that uniquely identifies the variable. Returns: a tensorflow variable. Raises: ValueError: if no variable uniquely identified by the name exists. """ candidates = tf.get_collection(tf.Grap...
def get_unique_variable(name): """Gets the variable uniquely identified by that name. Args: name: a name that uniquely identifies the variable. Returns: a tensorflow variable. Raises: ValueError: if no variable uniquely identified by the name exists. """ candidates = tf.get_collection(tf.Grap...
[ "Gets", "the", "variable", "uniquely", "identified", "by", "that", "name", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/variables.py#L152-L171
[ "def", "get_unique_variable", "(", "name", ")", ":", "candidates", "=", "tf", ".", "get_collection", "(", "tf", ".", "GraphKeys", ".", "GLOBAL_VARIABLES", ",", "name", ")", "if", "not", "candidates", ":", "raise", "ValueError", "(", "'Couldnt find variable %s'",...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
variable_device
Fix the variable device to colocate its ops.
examples/imagenet/inception/slim/variables.py
def variable_device(device, name): """Fix the variable device to colocate its ops.""" if callable(device): var_name = tf.get_variable_scope().name + '/' + name var_def = tf.NodeDef(name=var_name, op='Variable') device = device(var_def) if device is None: device = '' return device
def variable_device(device, name): """Fix the variable device to colocate its ops.""" if callable(device): var_name = tf.get_variable_scope().name + '/' + name var_def = tf.NodeDef(name=var_name, op='Variable') device = device(var_def) if device is None: device = '' return device
[ "Fix", "the", "variable", "device", "to", "colocate", "its", "ops", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/variables.py#L209-L217
[ "def", "variable_device", "(", "device", ",", "name", ")", ":", "if", "callable", "(", "device", ")", ":", "var_name", "=", "tf", ".", "get_variable_scope", "(", ")", ".", "name", "+", "'/'", "+", "name", "var_def", "=", "tf", ".", "NodeDef", "(", "n...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
global_step
Returns the global step variable. Args: device: Optional device to place the variable. It can be an string or a function that is called to get the device for the variable. Returns: the tensor representing the global step variable.
examples/imagenet/inception/slim/variables.py
def global_step(device=''): """Returns the global step variable. Args: device: Optional device to place the variable. It can be an string or a function that is called to get the device for the variable. Returns: the tensor representing the global step variable. """ global_step_ref = tf.get_col...
def global_step(device=''): """Returns the global step variable. Args: device: Optional device to place the variable. It can be an string or a function that is called to get the device for the variable. Returns: the tensor representing the global step variable. """ global_step_ref = tf.get_col...
[ "Returns", "the", "global", "step", "variable", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/variables.py#L221-L244
[ "def", "global_step", "(", "device", "=", "''", ")", ":", "global_step_ref", "=", "tf", ".", "get_collection", "(", "tf", ".", "GraphKeys", ".", "GLOBAL_STEP", ")", "if", "global_step_ref", ":", "return", "global_step_ref", "[", "0", "]", "else", ":", "col...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
variable
Gets an existing variable with these parameters or creates a new one. It also add itself to a group with its name. Args: name: the name of the new or existing variable. shape: shape of the new or existing variable. dtype: type of the new or existing variable (defaults to `DT_FLOAT`). initializer...
examples/imagenet/inception/slim/variables.py
def variable(name, shape=None, dtype=tf.float32, initializer=None, regularizer=None, trainable=True, collections=None, device='', restore=True): """Gets an existing variable with these parameters or creates a new one. It also add itself to a group with its name. Args: name: the n...
def variable(name, shape=None, dtype=tf.float32, initializer=None, regularizer=None, trainable=True, collections=None, device='', restore=True): """Gets an existing variable with these parameters or creates a new one. It also add itself to a group with its name. Args: name: the n...
[ "Gets", "an", "existing", "variable", "with", "these", "parameters", "or", "creates", "a", "new", "one", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/variables.py#L248-L289
[ "def", "variable", "(", "name", ",", "shape", "=", "None", ",", "dtype", "=", "tf", ".", "float32", ",", "initializer", "=", "None", ",", "regularizer", "=", "None", ",", "trainable", "=", "True", ",", "collections", "=", "None", ",", "device", "=", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_eval_once
Runs Eval once. Args: saver: Saver. summary_writer: Summary writer. top_1_op: Top 1 op. top_5_op: Top 5 op. summary_op: Summary op.
examples/imagenet/inception/inception_eval.py
def _eval_once(saver, summary_writer, top_1_op, top_5_op, summary_op): """Runs Eval once. Args: saver: Saver. summary_writer: Summary writer. top_1_op: Top 1 op. top_5_op: Top 5 op. summary_op: Summary op. """ with tf.Session() as sess: ckpt = tf.train.get_checkpoint_state(FLAGS.checkpo...
def _eval_once(saver, summary_writer, top_1_op, top_5_op, summary_op): """Runs Eval once. Args: saver: Saver. summary_writer: Summary writer. top_1_op: Top 1 op. top_5_op: Top 5 op. summary_op: Summary op. """ with tf.Session() as sess: ckpt = tf.train.get_checkpoint_state(FLAGS.checkpo...
[ "Runs", "Eval", "once", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/inception_eval.py#L55-L128
[ "def", "_eval_once", "(", "saver", ",", "summary_writer", ",", "top_1_op", ",", "top_5_op", ",", "summary_op", ")", ":", "with", "tf", ".", "Session", "(", ")", "as", "sess", ":", "ckpt", "=", "tf", ".", "train", ".", "get_checkpoint_state", "(", "FLAGS"...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
evaluate
Evaluate model on Dataset for a number of steps.
examples/imagenet/inception/inception_eval.py
def evaluate(dataset): """Evaluate model on Dataset for a number of steps.""" with tf.Graph().as_default(): # Get images and labels from the dataset. images, labels = image_processing.inputs(dataset) # Number of classes in the Dataset label set plus 1. # Label 0 is reserved for an (unused) backgrou...
def evaluate(dataset): """Evaluate model on Dataset for a number of steps.""" with tf.Graph().as_default(): # Get images and labels from the dataset. images, labels = image_processing.inputs(dataset) # Number of classes in the Dataset label set plus 1. # Label 0 is reserved for an (unused) backgrou...
[ "Evaluate", "model", "on", "Dataset", "for", "a", "number", "of", "steps", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/inception_eval.py#L131-L166
[ "def", "evaluate", "(", "dataset", ")", ":", "with", "tf", ".", "Graph", "(", ")", ".", "as_default", "(", ")", ":", "# Get images and labels from the dataset.", "images", ",", "labels", "=", "image_processing", ".", "inputs", "(", "dataset", ")", "# Number of...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_run_model
mapPartitions function to run single-node inferencing from a checkpoint/saved_model, using the model's input/output mappings. Args: :iterator: input RDD partition iterator. :args: arguments for TFModel, in argparse format :tf_args: arguments for TensorFlow inferencing code, in argparse or ARGV format. ...
tensorflowonspark/pipeline.py
def _run_model(iterator, args, tf_args): """mapPartitions function to run single-node inferencing from a checkpoint/saved_model, using the model's input/output mappings. Args: :iterator: input RDD partition iterator. :args: arguments for TFModel, in argparse format :tf_args: arguments for TensorFlow in...
def _run_model(iterator, args, tf_args): """mapPartitions function to run single-node inferencing from a checkpoint/saved_model, using the model's input/output mappings. Args: :iterator: input RDD partition iterator. :args: arguments for TFModel, in argparse format :tf_args: arguments for TensorFlow in...
[ "mapPartitions", "function", "to", "run", "single", "-", "node", "inferencing", "from", "a", "checkpoint", "/", "saved_model", "using", "the", "model", "s", "input", "/", "output", "mappings", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/pipeline.py#L483-L564
[ "def", "_run_model", "(", "iterator", ",", "args", ",", "tf_args", ")", ":", "single_node_env", "(", "tf_args", ")", "logging", ".", "info", "(", "\"===== input_mapping: {}\"", ".", "format", "(", "args", ".", "input_mapping", ")", ")", "logging", ".", "info...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
single_node_env
Sets up environment for a single-node TF session. Args: :args: command line arguments as either argparse args or argv list
tensorflowonspark/pipeline.py
def single_node_env(args): """Sets up environment for a single-node TF session. Args: :args: command line arguments as either argparse args or argv list """ # setup ARGV for the TF process if isinstance(args, list): sys.argv = args elif args.argv: sys.argv = args.argv # setup ENV for Had...
def single_node_env(args): """Sets up environment for a single-node TF session. Args: :args: command line arguments as either argparse args or argv list """ # setup ARGV for the TF process if isinstance(args, list): sys.argv = args elif args.argv: sys.argv = args.argv # setup ENV for Had...
[ "Sets", "up", "environment", "for", "a", "single", "-", "node", "TF", "session", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/pipeline.py#L567-L581
[ "def", "single_node_env", "(", "args", ")", ":", "# setup ARGV for the TF process", "if", "isinstance", "(", "args", ",", "list", ")", ":", "sys", ".", "argv", "=", "args", "elif", "args", ".", "argv", ":", "sys", ".", "argv", "=", "args", ".", "argv", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
get_meta_graph_def
Utility function to read a meta_graph_def from disk. From `saved_model_cli.py <https://github.com/tensorflow/tensorflow/blob/8e0e8d41a3a8f2d4a6100c2ea1dc9d6c6c4ad382/tensorflow/python/tools/saved_model_cli.py#L186>`_ Args: :saved_model_dir: path to saved_model. :tag_set: list of string tags identifying th...
tensorflowonspark/pipeline.py
def get_meta_graph_def(saved_model_dir, tag_set): """Utility function to read a meta_graph_def from disk. From `saved_model_cli.py <https://github.com/tensorflow/tensorflow/blob/8e0e8d41a3a8f2d4a6100c2ea1dc9d6c6c4ad382/tensorflow/python/tools/saved_model_cli.py#L186>`_ Args: :saved_model_dir: path to saved_...
def get_meta_graph_def(saved_model_dir, tag_set): """Utility function to read a meta_graph_def from disk. From `saved_model_cli.py <https://github.com/tensorflow/tensorflow/blob/8e0e8d41a3a8f2d4a6100c2ea1dc9d6c6c4ad382/tensorflow/python/tools/saved_model_cli.py#L186>`_ Args: :saved_model_dir: path to saved_...
[ "Utility", "function", "to", "read", "a", "meta_graph_def", "from", "disk", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/pipeline.py#L584-L601
[ "def", "get_meta_graph_def", "(", "saved_model_dir", ",", "tag_set", ")", ":", "saved_model", "=", "reader", ".", "read_saved_model", "(", "saved_model_dir", ")", "set_of_tags", "=", "set", "(", "tag_set", ".", "split", "(", "','", ")", ")", "for", "meta_graph...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
yield_batch
Generator that yields batches of a DataFrame iterator. Args: :iterable: Spark partition iterator. :batch_size: number of items to retrieve per invocation. :num_tensors: number of tensors (columns) expected in each item. Returns: An array of ``num_tensors`` arrays, each of length `batch_size`
tensorflowonspark/pipeline.py
def yield_batch(iterable, batch_size, num_tensors=1): """Generator that yields batches of a DataFrame iterator. Args: :iterable: Spark partition iterator. :batch_size: number of items to retrieve per invocation. :num_tensors: number of tensors (columns) expected in each item. Returns: An array o...
def yield_batch(iterable, batch_size, num_tensors=1): """Generator that yields batches of a DataFrame iterator. Args: :iterable: Spark partition iterator. :batch_size: number of items to retrieve per invocation. :num_tensors: number of tensors (columns) expected in each item. Returns: An array o...
[ "Generator", "that", "yields", "batches", "of", "a", "DataFrame", "iterator", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/pipeline.py#L604-L626
[ "def", "yield_batch", "(", "iterable", ",", "batch_size", ",", "num_tensors", "=", "1", ")", ":", "tensors", "=", "[", "[", "]", "for", "i", "in", "range", "(", "num_tensors", ")", "]", "for", "item", "in", "iterable", ":", "if", "item", "is", "None"...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
TFEstimator._fit
Trains a TensorFlow model and returns a TFModel instance with the same args/params pointing to a checkpoint or saved_model on disk. Args: :dataset: A Spark DataFrame with columns that will be mapped to TensorFlow tensors. Returns: A TFModel representing the trained model, backed on disk by a Tenso...
tensorflowonspark/pipeline.py
def _fit(self, dataset): """Trains a TensorFlow model and returns a TFModel instance with the same args/params pointing to a checkpoint or saved_model on disk. Args: :dataset: A Spark DataFrame with columns that will be mapped to TensorFlow tensors. Returns: A TFModel representing the trained ...
def _fit(self, dataset): """Trains a TensorFlow model and returns a TFModel instance with the same args/params pointing to a checkpoint or saved_model on disk. Args: :dataset: A Spark DataFrame with columns that will be mapped to TensorFlow tensors. Returns: A TFModel representing the trained ...
[ "Trains", "a", "TensorFlow", "model", "and", "returns", "a", "TFModel", "instance", "with", "the", "same", "args", "/", "params", "pointing", "to", "a", "checkpoint", "or", "saved_model", "on", "disk", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/pipeline.py#L368-L420
[ "def", "_fit", "(", "self", ",", "dataset", ")", ":", "sc", "=", "SparkContext", ".", "getOrCreate", "(", ")", "logging", ".", "info", "(", "\"===== 1. train args: {0}\"", ".", "format", "(", "self", ".", "args", ")", ")", "logging", ".", "info", "(", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
TFModel._transform
Transforms the input DataFrame by applying the _run_model() mapPartitions function. Args: :dataset: A Spark DataFrame for TensorFlow inferencing.
tensorflowonspark/pipeline.py
def _transform(self, dataset): """Transforms the input DataFrame by applying the _run_model() mapPartitions function. Args: :dataset: A Spark DataFrame for TensorFlow inferencing. """ spark = SparkSession.builder.getOrCreate() # set a deterministic order for input/output columns (lexicograph...
def _transform(self, dataset): """Transforms the input DataFrame by applying the _run_model() mapPartitions function. Args: :dataset: A Spark DataFrame for TensorFlow inferencing. """ spark = SparkSession.builder.getOrCreate() # set a deterministic order for input/output columns (lexicograph...
[ "Transforms", "the", "input", "DataFrame", "by", "applying", "the", "_run_model", "()", "mapPartitions", "function", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/pipeline.py#L448-L475
[ "def", "_transform", "(", "self", ",", "dataset", ")", ":", "spark", "=", "SparkSession", ".", "builder", ".", "getOrCreate", "(", ")", "# set a deterministic order for input/output columns (lexicographic by key)", "input_cols", "=", "[", "col", "for", "col", ",", "...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
run
Starts the TensorFlowOnSpark cluster and Runs the TensorFlow "main" function on the Spark executors Args: :sc: SparkContext :map_fun: user-supplied TensorFlow "main" function :tf_args: ``argparse`` args, or command-line ``ARGV``. These will be passed to the ``map_fun``. :num_executors: number of Spa...
tensorflowonspark/TFCluster.py
def run(sc, map_fun, tf_args, num_executors, num_ps, tensorboard=False, input_mode=InputMode.TENSORFLOW, log_dir=None, driver_ps_nodes=False, master_node=None, reservation_timeout=600, queues=['input', 'output', 'error'], eval_node=False): """Starts the TensorFlowOnSpark cluster and Runs the TensorFlo...
def run(sc, map_fun, tf_args, num_executors, num_ps, tensorboard=False, input_mode=InputMode.TENSORFLOW, log_dir=None, driver_ps_nodes=False, master_node=None, reservation_timeout=600, queues=['input', 'output', 'error'], eval_node=False): """Starts the TensorFlowOnSpark cluster and Runs the TensorFlo...
[ "Starts", "the", "TensorFlowOnSpark", "cluster", "and", "Runs", "the", "TensorFlow", "main", "function", "on", "the", "Spark", "executors" ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFCluster.py#L211-L379
[ "def", "run", "(", "sc", ",", "map_fun", ",", "tf_args", ",", "num_executors", ",", "num_ps", ",", "tensorboard", "=", "False", ",", "input_mode", "=", "InputMode", ".", "TENSORFLOW", ",", "log_dir", "=", "None", ",", "driver_ps_nodes", "=", "False", ",", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
TFCluster.train
*For InputMode.SPARK only*. Feeds Spark RDD partitions into the TensorFlow worker nodes It is the responsibility of the TensorFlow "main" function to interpret the rows of the RDD. Since epochs are implemented via ``RDD.union()`` and the entire RDD must generally be processed in full, it is recommended t...
tensorflowonspark/TFCluster.py
def train(self, dataRDD, num_epochs=0, feed_timeout=600, qname='input'): """*For InputMode.SPARK only*. Feeds Spark RDD partitions into the TensorFlow worker nodes It is the responsibility of the TensorFlow "main" function to interpret the rows of the RDD. Since epochs are implemented via ``RDD.union()``...
def train(self, dataRDD, num_epochs=0, feed_timeout=600, qname='input'): """*For InputMode.SPARK only*. Feeds Spark RDD partitions into the TensorFlow worker nodes It is the responsibility of the TensorFlow "main" function to interpret the rows of the RDD. Since epochs are implemented via ``RDD.union()``...
[ "*", "For", "InputMode", ".", "SPARK", "only", "*", ".", "Feeds", "Spark", "RDD", "partitions", "into", "the", "TensorFlow", "worker", "nodes" ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFCluster.py#L61-L92
[ "def", "train", "(", "self", ",", "dataRDD", ",", "num_epochs", "=", "0", ",", "feed_timeout", "=", "600", ",", "qname", "=", "'input'", ")", ":", "logging", ".", "info", "(", "\"Feeding training data\"", ")", "assert", "self", ".", "input_mode", "==", "...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
TFCluster.inference
*For InputMode.SPARK only*: Feeds Spark RDD partitions into the TensorFlow worker nodes and returns an RDD of results It is the responsibility of the TensorFlow "main" function to interpret the rows of the RDD and provide valid data for the output RDD. This will use the distributed TensorFlow cluster for infe...
tensorflowonspark/TFCluster.py
def inference(self, dataRDD, feed_timeout=600, qname='input'): """*For InputMode.SPARK only*: Feeds Spark RDD partitions into the TensorFlow worker nodes and returns an RDD of results It is the responsibility of the TensorFlow "main" function to interpret the rows of the RDD and provide valid data for the outp...
def inference(self, dataRDD, feed_timeout=600, qname='input'): """*For InputMode.SPARK only*: Feeds Spark RDD partitions into the TensorFlow worker nodes and returns an RDD of results It is the responsibility of the TensorFlow "main" function to interpret the rows of the RDD and provide valid data for the outp...
[ "*", "For", "InputMode", ".", "SPARK", "only", "*", ":", "Feeds", "Spark", "RDD", "partitions", "into", "the", "TensorFlow", "worker", "nodes", "and", "returns", "an", "RDD", "of", "results" ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFCluster.py#L94-L113
[ "def", "inference", "(", "self", ",", "dataRDD", ",", "feed_timeout", "=", "600", ",", "qname", "=", "'input'", ")", ":", "logging", ".", "info", "(", "\"Feeding inference data\"", ")", "assert", "self", ".", "input_mode", "==", "InputMode", ".", "SPARK", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
TFCluster.shutdown
Stops the distributed TensorFlow cluster. For InputMode.SPARK, this will be executed AFTER the `TFCluster.train()` or `TFCluster.inference()` method completes. For InputMode.TENSORFLOW, this will be executed IMMEDIATELY after `TFCluster.run()` and will wait until the TF worker nodes complete. Args: ...
tensorflowonspark/TFCluster.py
def shutdown(self, ssc=None, grace_secs=0, timeout=259200): """Stops the distributed TensorFlow cluster. For InputMode.SPARK, this will be executed AFTER the `TFCluster.train()` or `TFCluster.inference()` method completes. For InputMode.TENSORFLOW, this will be executed IMMEDIATELY after `TFCluster.run()` ...
def shutdown(self, ssc=None, grace_secs=0, timeout=259200): """Stops the distributed TensorFlow cluster. For InputMode.SPARK, this will be executed AFTER the `TFCluster.train()` or `TFCluster.inference()` method completes. For InputMode.TENSORFLOW, this will be executed IMMEDIATELY after `TFCluster.run()` ...
[ "Stops", "the", "distributed", "TensorFlow", "cluster", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFCluster.py#L115-L201
[ "def", "shutdown", "(", "self", ",", "ssc", "=", "None", ",", "grace_secs", "=", "0", ",", "timeout", "=", "259200", ")", ":", "logging", ".", "info", "(", "\"Stopping TensorFlow nodes\"", ")", "# identify ps/workers", "ps_list", ",", "worker_list", ",", "ev...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_int64_feature
Wrapper for inserting int64 features into Example proto.
examples/imagenet/inception/data/build_imagenet_data.py
def _int64_feature(value): """Wrapper for inserting int64 features into Example proto.""" if not isinstance(value, list): value = [value] return tf.train.Feature(int64_list=tf.train.Int64List(value=value))
def _int64_feature(value): """Wrapper for inserting int64 features into Example proto.""" if not isinstance(value, list): value = [value] return tf.train.Feature(int64_list=tf.train.Int64List(value=value))
[ "Wrapper", "for", "inserting", "int64", "features", "into", "Example", "proto", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_imagenet_data.py#L158-L162
[ "def", "_int64_feature", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "list", ")", ":", "value", "=", "[", "value", "]", "return", "tf", ".", "train", ".", "Feature", "(", "int64_list", "=", "tf", ".", "train", ".", "Int64Lis...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_float_feature
Wrapper for inserting float features into Example proto.
examples/imagenet/inception/data/build_imagenet_data.py
def _float_feature(value): """Wrapper for inserting float features into Example proto.""" if not isinstance(value, list): value = [value] return tf.train.Feature(float_list=tf.train.FloatList(value=value))
def _float_feature(value): """Wrapper for inserting float features into Example proto.""" if not isinstance(value, list): value = [value] return tf.train.Feature(float_list=tf.train.FloatList(value=value))
[ "Wrapper", "for", "inserting", "float", "features", "into", "Example", "proto", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_imagenet_data.py#L165-L169
[ "def", "_float_feature", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "list", ")", ":", "value", "=", "[", "value", "]", "return", "tf", ".", "train", ".", "Feature", "(", "float_list", "=", "tf", ".", "train", ".", "FloatLis...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_convert_to_example
Build an Example proto for an example. Args: filename: string, path to an image file, e.g., '/path/to/example.JPG' image_buffer: string, JPEG encoding of RGB image label: integer, identifier for the ground truth for the network synset: string, unique WordNet ID specifying the label, e.g., 'n02323233'...
examples/imagenet/inception/data/build_imagenet_data.py
def _convert_to_example(filename, image_buffer, label, synset, human, bbox, height, width): """Build an Example proto for an example. Args: filename: string, path to an image file, e.g., '/path/to/example.JPG' image_buffer: string, JPEG encoding of RGB image label: integer, iden...
def _convert_to_example(filename, image_buffer, label, synset, human, bbox, height, width): """Build an Example proto for an example. Args: filename: string, path to an image file, e.g., '/path/to/example.JPG' image_buffer: string, JPEG encoding of RGB image label: integer, iden...
[ "Build", "an", "Example", "proto", "for", "an", "example", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_imagenet_data.py#L177-L225
[ "def", "_convert_to_example", "(", "filename", ",", "image_buffer", ",", "label", ",", "synset", ",", "human", ",", "bbox", ",", "height", ",", "width", ")", ":", "xmin", "=", "[", "]", "ymin", "=", "[", "]", "xmax", "=", "[", "]", "ymax", "=", "["...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_process_image
Process a single image file. Args: filename: string, path to an image file e.g., '/path/to/example.JPG'. coder: instance of ImageCoder to provide TensorFlow image coding utils. Returns: image_buffer: string, JPEG encoding of RGB image. height: integer, image height in pixels. width: integer, im...
examples/imagenet/inception/data/build_imagenet_data.py
def _process_image(filename, coder): """Process a single image file. Args: filename: string, path to an image file e.g., '/path/to/example.JPG'. coder: instance of ImageCoder to provide TensorFlow image coding utils. Returns: image_buffer: string, JPEG encoding of RGB image. height: integer, imag...
def _process_image(filename, coder): """Process a single image file. Args: filename: string, path to an image file e.g., '/path/to/example.JPG'. coder: instance of ImageCoder to provide TensorFlow image coding utils. Returns: image_buffer: string, JPEG encoding of RGB image. height: integer, imag...
[ "Process", "a", "single", "image", "file", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_imagenet_data.py#L304-L338
[ "def", "_process_image", "(", "filename", ",", "coder", ")", ":", "# Read the image file.", "with", "tf", ".", "gfile", ".", "FastGFile", "(", "filename", ",", "'r'", ")", "as", "f", ":", "image_data", "=", "f", ".", "read", "(", ")", "# Clean the dirty da...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_find_human_readable_labels
Build a list of human-readable labels. Args: synsets: list of strings; each string is a unique WordNet ID. synset_to_human: dict of synset to human labels, e.g., 'n02119022' --> 'red fox, Vulpes vulpes' Returns: List of human-readable strings corresponding to each synset.
examples/imagenet/inception/data/build_imagenet_data.py
def _find_human_readable_labels(synsets, synset_to_human): """Build a list of human-readable labels. Args: synsets: list of strings; each string is a unique WordNet ID. synset_to_human: dict of synset to human labels, e.g., 'n02119022' --> 'red fox, Vulpes vulpes' Returns: List of human-readab...
def _find_human_readable_labels(synsets, synset_to_human): """Build a list of human-readable labels. Args: synsets: list of strings; each string is a unique WordNet ID. synset_to_human: dict of synset to human labels, e.g., 'n02119022' --> 'red fox, Vulpes vulpes' Returns: List of human-readab...
[ "Build", "a", "list", "of", "human", "-", "readable", "labels", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_imagenet_data.py#L540-L555
[ "def", "_find_human_readable_labels", "(", "synsets", ",", "synset_to_human", ")", ":", "humans", "=", "[", "]", "for", "s", "in", "synsets", ":", "assert", "s", "in", "synset_to_human", ",", "(", "'Failed to find: %s'", "%", "s", ")", "humans", ".", "append...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_find_image_bounding_boxes
Find the bounding boxes for a given image file. Args: filenames: list of strings; each string is a path to an image file. image_to_bboxes: dictionary mapping image file names to a list of bounding boxes. This list contains 0+ bounding boxes. Returns: List of bounding boxes for each image. Note th...
examples/imagenet/inception/data/build_imagenet_data.py
def _find_image_bounding_boxes(filenames, image_to_bboxes): """Find the bounding boxes for a given image file. Args: filenames: list of strings; each string is a path to an image file. image_to_bboxes: dictionary mapping image file names to a list of bounding boxes. This list contains 0+ bounding box...
def _find_image_bounding_boxes(filenames, image_to_bboxes): """Find the bounding boxes for a given image file. Args: filenames: list of strings; each string is a path to an image file. image_to_bboxes: dictionary mapping image file names to a list of bounding boxes. This list contains 0+ bounding box...
[ "Find", "the", "bounding", "boxes", "for", "a", "given", "image", "file", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_imagenet_data.py#L558-L581
[ "def", "_find_image_bounding_boxes", "(", "filenames", ",", "image_to_bboxes", ")", ":", "num_image_bbox", "=", "0", "bboxes", "=", "[", "]", "for", "f", "in", "filenames", ":", "basename", "=", "os", ".", "path", ".", "basename", "(", "f", ")", "if", "b...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_process_dataset
Process a complete data set and save it as a TFRecord. Args: name: string, unique identifier specifying the data set. directory: string, root path to the data set. num_shards: integer number of shards for this data set. synset_to_human: dict of synset to human labels, e.g., 'n02119022' --> 'red...
examples/imagenet/inception/data/build_imagenet_data.py
def _process_dataset(name, directory, num_shards, synset_to_human, image_to_bboxes): """Process a complete data set and save it as a TFRecord. Args: name: string, unique identifier specifying the data set. directory: string, root path to the data set. num_shards: integer number of ...
def _process_dataset(name, directory, num_shards, synset_to_human, image_to_bboxes): """Process a complete data set and save it as a TFRecord. Args: name: string, unique identifier specifying the data set. directory: string, root path to the data set. num_shards: integer number of ...
[ "Process", "a", "complete", "data", "set", "and", "save", "it", "as", "a", "TFRecord", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_imagenet_data.py#L584-L601
[ "def", "_process_dataset", "(", "name", ",", "directory", ",", "num_shards", ",", "synset_to_human", ",", "image_to_bboxes", ")", ":", "filenames", ",", "synsets", ",", "labels", "=", "_find_image_files", "(", "directory", ",", "FLAGS", ".", "labels_file", ")", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_build_synset_lookup
Build lookup for synset to human-readable label. Args: imagenet_metadata_file: string, path to file containing mapping from synset to human-readable label. Assumes each line of the file looks like: n02119247 black fox n02119359 silver fox n02119477 red fox, Vulpes f...
examples/imagenet/inception/data/build_imagenet_data.py
def _build_synset_lookup(imagenet_metadata_file): """Build lookup for synset to human-readable label. Args: imagenet_metadata_file: string, path to file containing mapping from synset to human-readable label. Assumes each line of the file looks like: n02119247 black fox n021193...
def _build_synset_lookup(imagenet_metadata_file): """Build lookup for synset to human-readable label. Args: imagenet_metadata_file: string, path to file containing mapping from synset to human-readable label. Assumes each line of the file looks like: n02119247 black fox n021193...
[ "Build", "lookup", "for", "synset", "to", "human", "-", "readable", "label", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_imagenet_data.py#L604-L633
[ "def", "_build_synset_lookup", "(", "imagenet_metadata_file", ")", ":", "lines", "=", "tf", ".", "gfile", ".", "FastGFile", "(", "imagenet_metadata_file", ",", "'r'", ")", ".", "readlines", "(", ")", "synset_to_human", "=", "{", "}", "for", "l", "in", "lines...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_build_bounding_box_lookup
Build a lookup from image file to bounding boxes. Args: bounding_box_file: string, path to file with bounding boxes annotations. Assumes each line of the file looks like: n00007846_64193.JPEG,0.0060,0.2620,0.7545,0.9940 where each line corresponds to one bounding box annotation associated ...
examples/imagenet/inception/data/build_imagenet_data.py
def _build_bounding_box_lookup(bounding_box_file): """Build a lookup from image file to bounding boxes. Args: bounding_box_file: string, path to file with bounding boxes annotations. Assumes each line of the file looks like: n00007846_64193.JPEG,0.0060,0.2620,0.7545,0.9940 where each lin...
def _build_bounding_box_lookup(bounding_box_file): """Build a lookup from image file to bounding boxes. Args: bounding_box_file: string, path to file with bounding boxes annotations. Assumes each line of the file looks like: n00007846_64193.JPEG,0.0060,0.2620,0.7545,0.9940 where each lin...
[ "Build", "a", "lookup", "from", "image", "file", "to", "bounding", "boxes", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_imagenet_data.py#L636-L681
[ "def", "_build_bounding_box_lookup", "(", "bounding_box_file", ")", ":", "lines", "=", "tf", ".", "gfile", ".", "FastGFile", "(", "bounding_box_file", ",", "'r'", ")", ".", "readlines", "(", ")", "images_to_bboxes", "=", "{", "}", "num_bbox", "=", "0", "num_...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
cnn_model_fn
Model function for CNN.
examples/mnist/estimator/mnist_estimator.py
def cnn_model_fn(features, labels, mode): """Model function for CNN.""" # Input Layer # Reshape X to 4-D tensor: [batch_size, width, height, channels] # MNIST images are 28x28 pixels, and have one color channel input_layer = tf.reshape(features["x"], [-1, 28, 28, 1]) # Convolutional Layer #1 # Computes 3...
def cnn_model_fn(features, labels, mode): """Model function for CNN.""" # Input Layer # Reshape X to 4-D tensor: [batch_size, width, height, channels] # MNIST images are 28x28 pixels, and have one color channel input_layer = tf.reshape(features["x"], [-1, 28, 28, 1]) # Convolutional Layer #1 # Computes 3...
[ "Model", "function", "for", "CNN", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/mnist/estimator/mnist_estimator.py#L26-L115
[ "def", "cnn_model_fn", "(", "features", ",", "labels", ",", "mode", ")", ":", "# Input Layer", "# Reshape X to 4-D tensor: [batch_size, width, height, channels]", "# MNIST images are 28x28 pixels, and have one color channel", "input_layer", "=", "tf", ".", "reshape", "(", "feat...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
read_cifar10
Reads and parses examples from CIFAR10 data files. Recommendation: if you want N-way read parallelism, call this function N times. This will give you N independent Readers reading different files & positions within those files, which will give better mixing of examples. Args: filename_queue: A queue of...
examples/cifar10/cifar10_input.py
def read_cifar10(filename_queue): """Reads and parses examples from CIFAR10 data files. Recommendation: if you want N-way read parallelism, call this function N times. This will give you N independent Readers reading different files & positions within those files, which will give better mixing of examples. ...
def read_cifar10(filename_queue): """Reads and parses examples from CIFAR10 data files. Recommendation: if you want N-way read parallelism, call this function N times. This will give you N independent Readers reading different files & positions within those files, which will give better mixing of examples. ...
[ "Reads", "and", "parses", "examples", "from", "CIFAR10", "data", "files", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10_input.py#L38-L98
[ "def", "read_cifar10", "(", "filename_queue", ")", ":", "class", "CIFAR10Record", "(", "object", ")", ":", "pass", "result", "=", "CIFAR10Record", "(", ")", "# Dimensions of the images in the CIFAR-10 dataset.", "# See http://www.cs.toronto.edu/~kriz/cifar.html for a descriptio...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_generate_image_and_label_batch
Construct a queued batch of images and labels. Args: image: 3-D Tensor of [height, width, 3] of type.float32. label: 1-D Tensor of type.int32 min_queue_examples: int32, minimum number of samples to retain in the queue that provides of batches of examples. batch_size: Number of images per batch....
examples/cifar10/cifar10_input.py
def _generate_image_and_label_batch(image, label, min_queue_examples, batch_size, shuffle): """Construct a queued batch of images and labels. Args: image: 3-D Tensor of [height, width, 3] of type.float32. label: 1-D Tensor of type.int32 min_queue_examples: int32, min...
def _generate_image_and_label_batch(image, label, min_queue_examples, batch_size, shuffle): """Construct a queued batch of images and labels. Args: image: 3-D Tensor of [height, width, 3] of type.float32. label: 1-D Tensor of type.int32 min_queue_examples: int32, min...
[ "Construct", "a", "queued", "batch", "of", "images", "and", "labels", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10_input.py#L101-L137
[ "def", "_generate_image_and_label_batch", "(", "image", ",", "label", ",", "min_queue_examples", ",", "batch_size", ",", "shuffle", ")", ":", "# Create a queue that shuffles the examples, and then", "# read 'batch_size' images + labels from the example queue.", "num_preprocess_thread...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
distorted_inputs
Construct distorted input for CIFAR training using the Reader ops. Args: data_dir: Path to the CIFAR-10 data directory. batch_size: Number of images per batch. Returns: images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size. labels: Labels. 1D tensor of [batch_size] size.
examples/cifar10/cifar10_input.py
def distorted_inputs(data_dir, batch_size): """Construct distorted input for CIFAR training using the Reader ops. Args: data_dir: Path to the CIFAR-10 data directory. batch_size: Number of images per batch. Returns: images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size. label...
def distorted_inputs(data_dir, batch_size): """Construct distorted input for CIFAR training using the Reader ops. Args: data_dir: Path to the CIFAR-10 data directory. batch_size: Number of images per batch. Returns: images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size. label...
[ "Construct", "distorted", "input", "for", "CIFAR", "training", "using", "the", "Reader", "ops", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10_input.py#L140-L200
[ "def", "distorted_inputs", "(", "data_dir", ",", "batch_size", ")", ":", "filenames", "=", "[", "os", ".", "path", ".", "join", "(", "data_dir", ",", "'data_batch_%d.bin'", "%", "i", ")", "for", "i", "in", "xrange", "(", "1", ",", "6", ")", "]", "for...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
inputs
Construct input for CIFAR evaluation using the Reader ops. Args: eval_data: bool, indicating if one should use the train or eval data set. data_dir: Path to the CIFAR-10 data directory. batch_size: Number of images per batch. Returns: images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZ...
examples/cifar10/cifar10_input.py
def inputs(eval_data, data_dir, batch_size): """Construct input for CIFAR evaluation using the Reader ops. Args: eval_data: bool, indicating if one should use the train or eval data set. data_dir: Path to the CIFAR-10 data directory. batch_size: Number of images per batch. Returns: images: Image...
def inputs(eval_data, data_dir, batch_size): """Construct input for CIFAR evaluation using the Reader ops. Args: eval_data: bool, indicating if one should use the train or eval data set. data_dir: Path to the CIFAR-10 data directory. batch_size: Number of images per batch. Returns: images: Image...
[ "Construct", "input", "for", "CIFAR", "evaluation", "using", "the", "Reader", "ops", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/cifar10/cifar10_input.py#L203-L257
[ "def", "inputs", "(", "eval_data", ",", "data_dir", ",", "batch_size", ")", ":", "if", "not", "eval_data", ":", "filenames", "=", "[", "os", ".", "path", ".", "join", "(", "data_dir", ",", "'data_batch_%d.bin'", "%", "i", ")", "for", "i", "in", "xrange...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
saveAsTFRecords
Save a Spark DataFrame as TFRecords. This will convert the DataFrame rows to TFRecords prior to saving. Args: :df: Spark DataFrame :output_dir: Path to save TFRecords
tensorflowonspark/dfutil.py
def saveAsTFRecords(df, output_dir): """Save a Spark DataFrame as TFRecords. This will convert the DataFrame rows to TFRecords prior to saving. Args: :df: Spark DataFrame :output_dir: Path to save TFRecords """ tf_rdd = df.rdd.mapPartitions(toTFExample(df.dtypes)) tf_rdd.saveAsNewAPIHadoopFile(out...
def saveAsTFRecords(df, output_dir): """Save a Spark DataFrame as TFRecords. This will convert the DataFrame rows to TFRecords prior to saving. Args: :df: Spark DataFrame :output_dir: Path to save TFRecords """ tf_rdd = df.rdd.mapPartitions(toTFExample(df.dtypes)) tf_rdd.saveAsNewAPIHadoopFile(out...
[ "Save", "a", "Spark", "DataFrame", "as", "TFRecords", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/dfutil.py#L29-L41
[ "def", "saveAsTFRecords", "(", "df", ",", "output_dir", ")", ":", "tf_rdd", "=", "df", ".", "rdd", ".", "mapPartitions", "(", "toTFExample", "(", "df", ".", "dtypes", ")", ")", "tf_rdd", ".", "saveAsNewAPIHadoopFile", "(", "output_dir", ",", "\"org.tensorflo...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
loadTFRecords
Load TFRecords from disk into a Spark DataFrame. This will attempt to automatically convert the tf.train.Example features into Spark DataFrame columns of equivalent types. Note: TensorFlow represents both strings and binary types as tf.train.BytesList, and we need to disambiguate these types for Spark DataFrame...
tensorflowonspark/dfutil.py
def loadTFRecords(sc, input_dir, binary_features=[]): """Load TFRecords from disk into a Spark DataFrame. This will attempt to automatically convert the tf.train.Example features into Spark DataFrame columns of equivalent types. Note: TensorFlow represents both strings and binary types as tf.train.BytesList, an...
def loadTFRecords(sc, input_dir, binary_features=[]): """Load TFRecords from disk into a Spark DataFrame. This will attempt to automatically convert the tf.train.Example features into Spark DataFrame columns of equivalent types. Note: TensorFlow represents both strings and binary types as tf.train.BytesList, an...
[ "Load", "TFRecords", "from", "disk", "into", "a", "Spark", "DataFrame", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/dfutil.py#L44-L81
[ "def", "loadTFRecords", "(", "sc", ",", "input_dir", ",", "binary_features", "=", "[", "]", ")", ":", "import", "tensorflow", "as", "tf", "tfr_rdd", "=", "sc", ".", "newAPIHadoopFile", "(", "input_dir", ",", "\"org.tensorflow.hadoop.io.TFRecordFileInputFormat\"", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
toTFExample
mapPartition function to convert a Spark RDD of Row into an RDD of serialized tf.train.Example bytestring. Note that tf.train.Example is a fairly flat structure with limited datatypes, e.g. tf.train.FloatList, tf.train.Int64List, and tf.train.BytesList, so most DataFrame types will be coerced into one of these typ...
tensorflowonspark/dfutil.py
def toTFExample(dtypes): """mapPartition function to convert a Spark RDD of Row into an RDD of serialized tf.train.Example bytestring. Note that tf.train.Example is a fairly flat structure with limited datatypes, e.g. tf.train.FloatList, tf.train.Int64List, and tf.train.BytesList, so most DataFrame types will be...
def toTFExample(dtypes): """mapPartition function to convert a Spark RDD of Row into an RDD of serialized tf.train.Example bytestring. Note that tf.train.Example is a fairly flat structure with limited datatypes, e.g. tf.train.FloatList, tf.train.Int64List, and tf.train.BytesList, so most DataFrame types will be...
[ "mapPartition", "function", "to", "convert", "a", "Spark", "RDD", "of", "Row", "into", "an", "RDD", "of", "serialized", "tf", ".", "train", ".", "Example", "bytestring", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/dfutil.py#L84-L131
[ "def", "toTFExample", "(", "dtypes", ")", ":", "def", "_toTFExample", "(", "iter", ")", ":", "# supported type mappings between DataFrame.dtypes and tf.train.Feature types", "float_dtypes", "=", "[", "'float'", ",", "'double'", "]", "int64_dtypes", "=", "[", "'boolean'"...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
infer_schema
Given a tf.train.Example, infer the Spark DataFrame schema (StructFields). Note: TensorFlow represents both strings and binary types as tf.train.BytesList, and we need to disambiguate these types for Spark DataFrames DTypes (StringType and BinaryType), so we require a "hint" from the caller in the ``binary_featu...
tensorflowonspark/dfutil.py
def infer_schema(example, binary_features=[]): """Given a tf.train.Example, infer the Spark DataFrame schema (StructFields). Note: TensorFlow represents both strings and binary types as tf.train.BytesList, and we need to disambiguate these types for Spark DataFrames DTypes (StringType and BinaryType), so we requ...
def infer_schema(example, binary_features=[]): """Given a tf.train.Example, infer the Spark DataFrame schema (StructFields). Note: TensorFlow represents both strings and binary types as tf.train.BytesList, and we need to disambiguate these types for Spark DataFrames DTypes (StringType and BinaryType), so we requ...
[ "Given", "a", "tf", ".", "train", ".", "Example", "infer", "the", "Spark", "DataFrame", "schema", "(", "StructFields", ")", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/dfutil.py#L134-L168
[ "def", "infer_schema", "(", "example", ",", "binary_features", "=", "[", "]", ")", ":", "def", "_infer_sql_type", "(", "k", ",", "v", ")", ":", "# special handling for binary features", "if", "k", "in", "binary_features", ":", "return", "BinaryType", "(", ")",...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
fromTFExample
mapPartition function to convert an RDD of serialized tf.train.Example bytestring into an RDD of Row. Note: TensorFlow represents both strings and binary types as tf.train.BytesList, and we need to disambiguate these types for Spark DataFrames DTypes (StringType and BinaryType), so we require a "hint" from the c...
tensorflowonspark/dfutil.py
def fromTFExample(iter, binary_features=[]): """mapPartition function to convert an RDD of serialized tf.train.Example bytestring into an RDD of Row. Note: TensorFlow represents both strings and binary types as tf.train.BytesList, and we need to disambiguate these types for Spark DataFrames DTypes (StringType an...
def fromTFExample(iter, binary_features=[]): """mapPartition function to convert an RDD of serialized tf.train.Example bytestring into an RDD of Row. Note: TensorFlow represents both strings and binary types as tf.train.BytesList, and we need to disambiguate these types for Spark DataFrames DTypes (StringType an...
[ "mapPartition", "function", "to", "convert", "an", "RDD", "of", "serialized", "tf", ".", "train", ".", "Example", "bytestring", "into", "an", "RDD", "of", "Row", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/dfutil.py#L171-L212
[ "def", "fromTFExample", "(", "iter", ",", "binary_features", "=", "[", "]", ")", ":", "# convert from protobuf-like dict to DataFrame-friendly dict", "def", "_get_value", "(", "k", ",", "v", ")", ":", "if", "v", ".", "int64_list", ".", "value", ":", "result", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
build_estimator
Build an estimator appropriate for the given model type.
examples/wide_deep/census_main.py
def build_estimator(model_dir, model_type, model_column_fn, inter_op, intra_op, ctx): """Build an estimator appropriate for the given model type.""" wide_columns, deep_columns = model_column_fn() hidden_units = [100, 75, 50, 25] # Create a tf.estimator.RunConfig to ensure the model is run on CPU, which # tra...
def build_estimator(model_dir, model_type, model_column_fn, inter_op, intra_op, ctx): """Build an estimator appropriate for the given model type.""" wide_columns, deep_columns = model_column_fn() hidden_units = [100, 75, 50, 25] # Create a tf.estimator.RunConfig to ensure the model is run on CPU, which # tra...
[ "Build", "an", "estimator", "appropriate", "for", "the", "given", "model", "type", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/census_main.py#L46-L77
[ "def", "build_estimator", "(", "model_dir", ",", "model_type", ",", "model_column_fn", ",", "inter_op", ",", "intra_op", ",", "ctx", ")", ":", "wide_columns", ",", "deep_columns", "=", "model_column_fn", "(", ")", "hidden_units", "=", "[", "100", ",", "75", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
run_census
Construct all necessary functions and call run_loop. Args: flags_obj: Object containing user specified flags.
examples/wide_deep/census_main.py
def run_census(flags_obj, ctx): """Construct all necessary functions and call run_loop. Args: flags_obj: Object containing user specified flags. """ train_file = os.path.join(flags_obj.data_dir, census_dataset.TRAINING_FILE) test_file = os.path.join(flags_obj.data_dir, census_dataset.EVAL_FILE) # Trai...
def run_census(flags_obj, ctx): """Construct all necessary functions and call run_loop. Args: flags_obj: Object containing user specified flags. """ train_file = os.path.join(flags_obj.data_dir, census_dataset.TRAINING_FILE) test_file = os.path.join(flags_obj.data_dir, census_dataset.EVAL_FILE) # Trai...
[ "Construct", "all", "necessary", "functions", "and", "call", "run_loop", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/census_main.py#L80-L122
[ "def", "run_census", "(", "flags_obj", ",", "ctx", ")", ":", "train_file", "=", "os", ".", "path", ".", "join", "(", "flags_obj", ".", "data_dir", ",", "census_dataset", ".", "TRAINING_FILE", ")", "test_file", "=", "os", ".", "path", ".", "join", "(", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
inception_v3
Latest Inception from http://arxiv.org/abs/1512.00567. "Rethinking the Inception Architecture for Computer Vision" Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, Zbigniew Wojna Args: inputs: a tensor of size [batch_size, height, width, channels]. dropout_keep_prob: dropout...
examples/imagenet/inception/slim/inception_model.py
def inception_v3(inputs, dropout_keep_prob=0.8, num_classes=1000, is_training=True, restore_logits=True, scope=''): """Latest Inception from http://arxiv.org/abs/1512.00567. "Rethinking the Inception Architecture for Computer Vi...
def inception_v3(inputs, dropout_keep_prob=0.8, num_classes=1000, is_training=True, restore_logits=True, scope=''): """Latest Inception from http://arxiv.org/abs/1512.00567. "Rethinking the Inception Architecture for Computer Vi...
[ "Latest", "Inception", "from", "http", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1512", ".", "00567", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/inception_model.py#L52-L330
[ "def", "inception_v3", "(", "inputs", ",", "dropout_keep_prob", "=", "0.8", ",", "num_classes", "=", "1000", ",", "is_training", "=", "True", ",", "restore_logits", "=", "True", ",", "scope", "=", "''", ")", ":", "# end_points will collect relevant activations for...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
inception_v3_parameters
Yields the scope with the default parameters for inception_v3. Args: weight_decay: the weight decay for weights variables. stddev: standard deviation of the truncated guassian weight distribution. batch_norm_decay: decay for the moving average of batch_norm momentums. batch_norm_epsilon: small float ...
examples/imagenet/inception/slim/inception_model.py
def inception_v3_parameters(weight_decay=0.00004, stddev=0.1, batch_norm_decay=0.9997, batch_norm_epsilon=0.001): """Yields the scope with the default parameters for inception_v3. Args: weight_decay: the weight decay for weights variables. stddev: standard deviation of the trunc...
def inception_v3_parameters(weight_decay=0.00004, stddev=0.1, batch_norm_decay=0.9997, batch_norm_epsilon=0.001): """Yields the scope with the default parameters for inception_v3. Args: weight_decay: the weight decay for weights variables. stddev: standard deviation of the trunc...
[ "Yields", "the", "scope", "with", "the", "default", "parameters", "for", "inception_v3", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/inception_model.py#L333-L356
[ "def", "inception_v3_parameters", "(", "weight_decay", "=", "0.00004", ",", "stddev", "=", "0.1", ",", "batch_norm_decay", "=", "0.9997", ",", "batch_norm_epsilon", "=", "0.001", ")", ":", "# Set weight_decay for weights in Conv and FC layers.", "with", "scopes", ".", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
single_node_env
Setup environment variables for Hadoop compatibility and GPU allocation
tensorflowonspark/util.py
def single_node_env(num_gpus=1): """Setup environment variables for Hadoop compatibility and GPU allocation""" import tensorflow as tf # ensure expanded CLASSPATH w/o glob characters (required for Spark 2.1 + JNI) if 'HADOOP_PREFIX' in os.environ and 'TFOS_CLASSPATH_UPDATED' not in os.environ: classpath =...
def single_node_env(num_gpus=1): """Setup environment variables for Hadoop compatibility and GPU allocation""" import tensorflow as tf # ensure expanded CLASSPATH w/o glob characters (required for Spark 2.1 + JNI) if 'HADOOP_PREFIX' in os.environ and 'TFOS_CLASSPATH_UPDATED' not in os.environ: classpath =...
[ "Setup", "environment", "variables", "for", "Hadoop", "compatibility", "and", "GPU", "allocation" ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/util.py#L19-L38
[ "def", "single_node_env", "(", "num_gpus", "=", "1", ")", ":", "import", "tensorflow", "as", "tf", "# ensure expanded CLASSPATH w/o glob characters (required for Spark 2.1 + JNI)", "if", "'HADOOP_PREFIX'", "in", "os", ".", "environ", "and", "'TFOS_CLASSPATH_UPDATED'", "not"...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
get_ip_address
Simple utility to get host IP address.
tensorflowonspark/util.py
def get_ip_address(): """Simple utility to get host IP address.""" try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) ip_address = s.getsockname()[0] except socket_error as sockerr: if sockerr.errno != errno.ENETUNREACH: raise sockerr ip_address = socket...
def get_ip_address(): """Simple utility to get host IP address.""" try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) ip_address = s.getsockname()[0] except socket_error as sockerr: if sockerr.errno != errno.ENETUNREACH: raise sockerr ip_address = socket...
[ "Simple", "utility", "to", "get", "host", "IP", "address", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/util.py#L41-L54
[ "def", "get_ip_address", "(", ")", ":", "try", ":", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_DGRAM", ")", "s", ".", "connect", "(", "(", "\"8.8.8.8\"", ",", "80", ")", ")", "ip_address", "=", "s", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
find_in_path
Find a file in a given path string.
tensorflowonspark/util.py
def find_in_path(path, file): """Find a file in a given path string.""" for p in path.split(os.pathsep): candidate = os.path.join(p, file) if os.path.exists(candidate) and os.path.isfile(candidate): return candidate return False
def find_in_path(path, file): """Find a file in a given path string.""" for p in path.split(os.pathsep): candidate = os.path.join(p, file) if os.path.exists(candidate) and os.path.isfile(candidate): return candidate return False
[ "Find", "a", "file", "in", "a", "given", "path", "string", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/util.py#L57-L63
[ "def", "find_in_path", "(", "path", ",", "file", ")", ":", "for", "p", "in", "path", ".", "split", "(", "os", ".", "pathsep", ")", ":", "candidate", "=", "os", ".", "path", ".", "join", "(", "p", ",", "file", ")", "if", "os", ".", "path", ".", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
l1_regularizer
Define a L1 regularizer. Args: weight: scale the loss by this factor. scope: Optional scope for name_scope. Returns: a regularizer function.
examples/imagenet/inception/slim/losses.py
def l1_regularizer(weight=1.0, scope=None): """Define a L1 regularizer. Args: weight: scale the loss by this factor. scope: Optional scope for name_scope. Returns: a regularizer function. """ def regularizer(tensor): with tf.name_scope(scope, 'L1Regularizer', [tensor]): l1_weight = tf....
def l1_regularizer(weight=1.0, scope=None): """Define a L1 regularizer. Args: weight: scale the loss by this factor. scope: Optional scope for name_scope. Returns: a regularizer function. """ def regularizer(tensor): with tf.name_scope(scope, 'L1Regularizer', [tensor]): l1_weight = tf....
[ "Define", "a", "L1", "regularizer", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L37-L53
[ "def", "l1_regularizer", "(", "weight", "=", "1.0", ",", "scope", "=", "None", ")", ":", "def", "regularizer", "(", "tensor", ")", ":", "with", "tf", ".", "name_scope", "(", "scope", ",", "'L1Regularizer'", ",", "[", "tensor", "]", ")", ":", "l1_weight...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
l2_regularizer
Define a L2 regularizer. Args: weight: scale the loss by this factor. scope: Optional scope for name_scope. Returns: a regularizer function.
examples/imagenet/inception/slim/losses.py
def l2_regularizer(weight=1.0, scope=None): """Define a L2 regularizer. Args: weight: scale the loss by this factor. scope: Optional scope for name_scope. Returns: a regularizer function. """ def regularizer(tensor): with tf.name_scope(scope, 'L2Regularizer', [tensor]): l2_weight = tf....
def l2_regularizer(weight=1.0, scope=None): """Define a L2 regularizer. Args: weight: scale the loss by this factor. scope: Optional scope for name_scope. Returns: a regularizer function. """ def regularizer(tensor): with tf.name_scope(scope, 'L2Regularizer', [tensor]): l2_weight = tf....
[ "Define", "a", "L2", "regularizer", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L56-L72
[ "def", "l2_regularizer", "(", "weight", "=", "1.0", ",", "scope", "=", "None", ")", ":", "def", "regularizer", "(", "tensor", ")", ":", "with", "tf", ".", "name_scope", "(", "scope", ",", "'L2Regularizer'", ",", "[", "tensor", "]", ")", ":", "l2_weight...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
l1_l2_regularizer
Define a L1L2 regularizer. Args: weight_l1: scale the L1 loss by this factor. weight_l2: scale the L2 loss by this factor. scope: Optional scope for name_scope. Returns: a regularizer function.
examples/imagenet/inception/slim/losses.py
def l1_l2_regularizer(weight_l1=1.0, weight_l2=1.0, scope=None): """Define a L1L2 regularizer. Args: weight_l1: scale the L1 loss by this factor. weight_l2: scale the L2 loss by this factor. scope: Optional scope for name_scope. Returns: a regularizer function. """ def regularizer(tensor): ...
def l1_l2_regularizer(weight_l1=1.0, weight_l2=1.0, scope=None): """Define a L1L2 regularizer. Args: weight_l1: scale the L1 loss by this factor. weight_l2: scale the L2 loss by this factor. scope: Optional scope for name_scope. Returns: a regularizer function. """ def regularizer(tensor): ...
[ "Define", "a", "L1L2", "regularizer", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L75-L99
[ "def", "l1_l2_regularizer", "(", "weight_l1", "=", "1.0", ",", "weight_l2", "=", "1.0", ",", "scope", "=", "None", ")", ":", "def", "regularizer", "(", "tensor", ")", ":", "with", "tf", ".", "name_scope", "(", "scope", ",", "'L1L2Regularizer'", ",", "[",...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
l1_loss
Define a L1Loss, useful for regularize, i.e. lasso. Args: tensor: tensor to regularize. weight: scale the loss by this factor. scope: Optional scope for name_scope. Returns: the L1 loss op.
examples/imagenet/inception/slim/losses.py
def l1_loss(tensor, weight=1.0, scope=None): """Define a L1Loss, useful for regularize, i.e. lasso. Args: tensor: tensor to regularize. weight: scale the loss by this factor. scope: Optional scope for name_scope. Returns: the L1 loss op. """ with tf.name_scope(scope, 'L1Loss', [tensor]): ...
def l1_loss(tensor, weight=1.0, scope=None): """Define a L1Loss, useful for regularize, i.e. lasso. Args: tensor: tensor to regularize. weight: scale the loss by this factor. scope: Optional scope for name_scope. Returns: the L1 loss op. """ with tf.name_scope(scope, 'L1Loss', [tensor]): ...
[ "Define", "a", "L1Loss", "useful", "for", "regularize", "i", ".", "e", ".", "lasso", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L102-L119
[ "def", "l1_loss", "(", "tensor", ",", "weight", "=", "1.0", ",", "scope", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "scope", ",", "'L1Loss'", ",", "[", "tensor", "]", ")", ":", "weight", "=", "tf", ".", "convert_to_tensor", "(", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
l2_loss
Define a L2Loss, useful for regularize, i.e. weight decay. Args: tensor: tensor to regularize. weight: an optional weight to modulate the loss. scope: Optional scope for name_scope. Returns: the L2 loss op.
examples/imagenet/inception/slim/losses.py
def l2_loss(tensor, weight=1.0, scope=None): """Define a L2Loss, useful for regularize, i.e. weight decay. Args: tensor: tensor to regularize. weight: an optional weight to modulate the loss. scope: Optional scope for name_scope. Returns: the L2 loss op. """ with tf.name_scope(scope, 'L2Loss...
def l2_loss(tensor, weight=1.0, scope=None): """Define a L2Loss, useful for regularize, i.e. weight decay. Args: tensor: tensor to regularize. weight: an optional weight to modulate the loss. scope: Optional scope for name_scope. Returns: the L2 loss op. """ with tf.name_scope(scope, 'L2Loss...
[ "Define", "a", "L2Loss", "useful", "for", "regularize", "i", ".", "e", ".", "weight", "decay", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L122-L139
[ "def", "l2_loss", "(", "tensor", ",", "weight", "=", "1.0", ",", "scope", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "scope", ",", "'L2Loss'", ",", "[", "tensor", "]", ")", ":", "weight", "=", "tf", ".", "convert_to_tensor", "(", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
cross_entropy_loss
Define a Cross Entropy loss using softmax_cross_entropy_with_logits. It can scale the loss by weight factor, and smooth the labels. Args: logits: [batch_size, num_classes] logits outputs of the network . one_hot_labels: [batch_size, num_classes] target one_hot_encoded labels. label_smoothing: if great...
examples/imagenet/inception/slim/losses.py
def cross_entropy_loss(logits, one_hot_labels, label_smoothing=0, weight=1.0, scope=None): """Define a Cross Entropy loss using softmax_cross_entropy_with_logits. It can scale the loss by weight factor, and smooth the labels. Args: logits: [batch_size, num_classes] logits outputs of t...
def cross_entropy_loss(logits, one_hot_labels, label_smoothing=0, weight=1.0, scope=None): """Define a Cross Entropy loss using softmax_cross_entropy_with_logits. It can scale the loss by weight factor, and smooth the labels. Args: logits: [batch_size, num_classes] logits outputs of t...
[ "Define", "a", "Cross", "Entropy", "loss", "using", "softmax_cross_entropy_with_logits", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L142-L174
[ "def", "cross_entropy_loss", "(", "logits", ",", "one_hot_labels", ",", "label_smoothing", "=", "0", ",", "weight", "=", "1.0", ",", "scope", "=", "None", ")", ":", "logits", ".", "get_shape", "(", ")", ".", "assert_is_compatible_with", "(", "one_hot_labels", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
arg_scope
Stores the default arguments for the given set of list_ops. For usage, please see examples at top of the file. Args: list_ops_or_scope: List or tuple of operations to set argument scope for or a dictionary containg the current scope. When list_ops_or_scope is a dict, kwargs must be empty. When lis...
examples/imagenet/inception/slim/scopes.py
def arg_scope(list_ops_or_scope, **kwargs): """Stores the default arguments for the given set of list_ops. For usage, please see examples at top of the file. Args: list_ops_or_scope: List or tuple of operations to set argument scope for or a dictionary containg the current scope. When list_ops_or_scop...
def arg_scope(list_ops_or_scope, **kwargs): """Stores the default arguments for the given set of list_ops. For usage, please see examples at top of the file. Args: list_ops_or_scope: List or tuple of operations to set argument scope for or a dictionary containg the current scope. When list_ops_or_scop...
[ "Stores", "the", "default", "arguments", "for", "the", "given", "set", "of", "list_ops", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/scopes.py#L85-L135
[ "def", "arg_scope", "(", "list_ops_or_scope", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "list_ops_or_scope", ",", "dict", ")", ":", "# Assumes that list_ops_or_scope is a scope that is being reused.", "if", "kwargs", ":", "raise", "ValueError", "(", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
add_arg_scope
Decorates a function with args so it can be used within an arg_scope. Args: func: function to decorate. Returns: A tuple with the decorated function func_with_args().
examples/imagenet/inception/slim/scopes.py
def add_arg_scope(func): """Decorates a function with args so it can be used within an arg_scope. Args: func: function to decorate. Returns: A tuple with the decorated function func_with_args(). """ @functools.wraps(func) def func_with_args(*args, **kwargs): current_scope = _current_arg_scope(...
def add_arg_scope(func): """Decorates a function with args so it can be used within an arg_scope. Args: func: function to decorate. Returns: A tuple with the decorated function func_with_args(). """ @functools.wraps(func) def func_with_args(*args, **kwargs): current_scope = _current_arg_scope(...
[ "Decorates", "a", "function", "with", "args", "so", "it", "can", "be", "used", "within", "an", "arg_scope", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/scopes.py#L138-L157
[ "def", "add_arg_scope", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "func_with_args", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "current_scope", "=", "_current_arg_scope", "(", ")", "current_args", "=", "kwa...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_get_manager
Returns this executor's "singleton" instance of the multiprocessing.Manager, reconnecting per python-worker if needed. Args: :cluster_info: cluster node reservations :host: host IP address :executor_id: unique id per executor (created during initial call to run()) Returns: TFManager instance for t...
tensorflowonspark/TFSparkNode.py
def _get_manager(cluster_info, host, executor_id): """Returns this executor's "singleton" instance of the multiprocessing.Manager, reconnecting per python-worker if needed. Args: :cluster_info: cluster node reservations :host: host IP address :executor_id: unique id per executor (created during initial...
def _get_manager(cluster_info, host, executor_id): """Returns this executor's "singleton" instance of the multiprocessing.Manager, reconnecting per python-worker if needed. Args: :cluster_info: cluster node reservations :host: host IP address :executor_id: unique id per executor (created during initial...
[ "Returns", "this", "executor", "s", "singleton", "instance", "of", "the", "multiprocessing", ".", "Manager", "reconnecting", "per", "python", "-", "worker", "if", "needed", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L91-L117
[ "def", "_get_manager", "(", "cluster_info", ",", "host", ",", "executor_id", ")", ":", "for", "node", "in", "cluster_info", ":", "if", "node", "[", "'host'", "]", "==", "host", "and", "node", "[", "'executor_id'", "]", "==", "executor_id", ":", "addr", "...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
run
Wraps the user-provided TensorFlow main function in a Spark mapPartitions function. Args: :fn: TensorFlow "main" function provided by the user. :tf_args: ``argparse`` args, or command line ``ARGV``. These will be passed to the ``fn``. :cluster_meta: dictionary of cluster metadata (e.g. cluster_id, reser...
tensorflowonspark/TFSparkNode.py
def run(fn, tf_args, cluster_meta, tensorboard, log_dir, queues, background): """Wraps the user-provided TensorFlow main function in a Spark mapPartitions function. Args: :fn: TensorFlow "main" function provided by the user. :tf_args: ``argparse`` args, or command line ``ARGV``. These will be passed to th...
def run(fn, tf_args, cluster_meta, tensorboard, log_dir, queues, background): """Wraps the user-provided TensorFlow main function in a Spark mapPartitions function. Args: :fn: TensorFlow "main" function provided by the user. :tf_args: ``argparse`` args, or command line ``ARGV``. These will be passed to th...
[ "Wraps", "the", "user", "-", "provided", "TensorFlow", "main", "function", "in", "a", "Spark", "mapPartitions", "function", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L120-L369
[ "def", "run", "(", "fn", ",", "tf_args", ",", "cluster_meta", ",", "tensorboard", ",", "log_dir", ",", "queues", ",", "background", ")", ":", "def", "_mapfn", "(", "iter", ")", ":", "import", "tensorflow", "as", "tf", "# Note: consuming the input iterator help...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
train
Feeds Spark partitions into the shared multiprocessing.Queue. Args: :cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc) :cluster_meta: dictionary of cluster metadata (e.g. cluster_id, reservation.Server address, etc) :feed_timeout: number of seconds after...
tensorflowonspark/TFSparkNode.py
def train(cluster_info, cluster_meta, feed_timeout=600, qname='input'): """Feeds Spark partitions into the shared multiprocessing.Queue. Args: :cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc) :cluster_meta: dictionary of cluster metadata (e.g. cluster_id...
def train(cluster_info, cluster_meta, feed_timeout=600, qname='input'): """Feeds Spark partitions into the shared multiprocessing.Queue. Args: :cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc) :cluster_meta: dictionary of cluster metadata (e.g. cluster_id...
[ "Feeds", "Spark", "partitions", "into", "the", "shared", "multiprocessing", ".", "Queue", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L372-L440
[ "def", "train", "(", "cluster_info", ",", "cluster_meta", ",", "feed_timeout", "=", "600", ",", "qname", "=", "'input'", ")", ":", "def", "_train", "(", "iter", ")", ":", "# get shared queue, reconnecting if necessary", "mgr", "=", "_get_manager", "(", "cluster_...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
inference
Feeds Spark partitions into the shared multiprocessing.Queue and returns inference results. Args: :cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc) :feed_timeout: number of seconds after which data feeding times out (600 sec default) :qname: *INTERNAL_U...
tensorflowonspark/TFSparkNode.py
def inference(cluster_info, feed_timeout=600, qname='input'): """Feeds Spark partitions into the shared multiprocessing.Queue and returns inference results. Args: :cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc) :feed_timeout: number of seconds after whi...
def inference(cluster_info, feed_timeout=600, qname='input'): """Feeds Spark partitions into the shared multiprocessing.Queue and returns inference results. Args: :cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc) :feed_timeout: number of seconds after whi...
[ "Feeds", "Spark", "partitions", "into", "the", "shared", "multiprocessing", ".", "Queue", "and", "returns", "inference", "results", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L443-L505
[ "def", "inference", "(", "cluster_info", ",", "feed_timeout", "=", "600", ",", "qname", "=", "'input'", ")", ":", "def", "_inference", "(", "iter", ")", ":", "# get shared queue, reconnecting if necessary", "mgr", "=", "_get_manager", "(", "cluster_info", ",", "...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
shutdown
Stops all TensorFlow nodes by feeding ``None`` into the multiprocessing.Queues. Args: :cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc). :queues: *INTERNAL_USE* Returns: A nodeRDD.mapPartitions() function
tensorflowonspark/TFSparkNode.py
def shutdown(cluster_info, queues=['input']): """Stops all TensorFlow nodes by feeding ``None`` into the multiprocessing.Queues. Args: :cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc). :queues: *INTERNAL_USE* Returns: A nodeRDD.mapPartitions() fun...
def shutdown(cluster_info, queues=['input']): """Stops all TensorFlow nodes by feeding ``None`` into the multiprocessing.Queues. Args: :cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc). :queues: *INTERNAL_USE* Returns: A nodeRDD.mapPartitions() fun...
[ "Stops", "all", "TensorFlow", "nodes", "by", "feeding", "None", "into", "the", "multiprocessing", ".", "Queues", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L508-L548
[ "def", "shutdown", "(", "cluster_info", ",", "queues", "=", "[", "'input'", "]", ")", ":", "def", "_shutdown", "(", "iter", ")", ":", "host", "=", "util", ".", "get_ip_address", "(", ")", "executor_id", "=", "util", ".", "read_executor_id", "(", ")", "...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
TFNodeContext.start_cluster_server
Convenience function to access ``TFNode.start_cluster_server`` directly from this object instance.
tensorflowonspark/TFSparkNode.py
def start_cluster_server(self, num_gpus=1, rdma=False): """Convenience function to access ``TFNode.start_cluster_server`` directly from this object instance.""" return TFNode.start_cluster_server(self, num_gpus, rdma)
def start_cluster_server(self, num_gpus=1, rdma=False): """Convenience function to access ``TFNode.start_cluster_server`` directly from this object instance.""" return TFNode.start_cluster_server(self, num_gpus, rdma)
[ "Convenience", "function", "to", "access", "TFNode", ".", "start_cluster_server", "directly", "from", "this", "object", "instance", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L61-L63
[ "def", "start_cluster_server", "(", "self", ",", "num_gpus", "=", "1", ",", "rdma", "=", "False", ")", ":", "return", "TFNode", ".", "start_cluster_server", "(", "self", ",", "num_gpus", ",", "rdma", ")" ]
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
TFNodeContext.export_saved_model
Convenience function to access ``TFNode.export_saved_model`` directly from this object instance.
tensorflowonspark/TFSparkNode.py
def export_saved_model(self, sess, export_dir, tag_set, signatures): """Convenience function to access ``TFNode.export_saved_model`` directly from this object instance.""" TFNode.export_saved_model(sess, export_dir, tag_set, signatures)
def export_saved_model(self, sess, export_dir, tag_set, signatures): """Convenience function to access ``TFNode.export_saved_model`` directly from this object instance.""" TFNode.export_saved_model(sess, export_dir, tag_set, signatures)
[ "Convenience", "function", "to", "access", "TFNode", ".", "export_saved_model", "directly", "from", "this", "object", "instance", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L65-L67
[ "def", "export_saved_model", "(", "self", ",", "sess", ",", "export_dir", ",", "tag_set", ",", "signatures", ")", ":", "TFNode", ".", "export_saved_model", "(", "sess", ",", "export_dir", ",", "tag_set", ",", "signatures", ")" ]
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
TFNodeContext.get_data_feed
Convenience function to access ``TFNode.DataFeed`` directly from this object instance.
tensorflowonspark/TFSparkNode.py
def get_data_feed(self, train_mode=True, qname_in='input', qname_out='output', input_mapping=None): """Convenience function to access ``TFNode.DataFeed`` directly from this object instance.""" return TFNode.DataFeed(self.mgr, train_mode, qname_in, qname_out, input_mapping)
def get_data_feed(self, train_mode=True, qname_in='input', qname_out='output', input_mapping=None): """Convenience function to access ``TFNode.DataFeed`` directly from this object instance.""" return TFNode.DataFeed(self.mgr, train_mode, qname_in, qname_out, input_mapping)
[ "Convenience", "function", "to", "access", "TFNode", ".", "DataFeed", "directly", "from", "this", "object", "instance", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L69-L71
[ "def", "get_data_feed", "(", "self", ",", "train_mode", "=", "True", ",", "qname_in", "=", "'input'", ",", "qname_out", "=", "'output'", ",", "input_mapping", "=", "None", ")", ":", "return", "TFNode", ".", "DataFeed", "(", "self", ".", "mgr", ",", "trai...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
_download_and_clean_file
Downloads data from url, and makes changes to match the CSV format.
examples/wide_deep/census_dataset.py
def _download_and_clean_file(filename, url): """Downloads data from url, and makes changes to match the CSV format.""" temp_file, _ = urllib.request.urlretrieve(url) with tf.gfile.Open(temp_file, 'r') as temp_eval_file: with tf.gfile.Open(filename, 'w') as eval_file: for line in temp_eval_file: ...
def _download_and_clean_file(filename, url): """Downloads data from url, and makes changes to match the CSV format.""" temp_file, _ = urllib.request.urlretrieve(url) with tf.gfile.Open(temp_file, 'r') as temp_eval_file: with tf.gfile.Open(filename, 'w') as eval_file: for line in temp_eval_file: ...
[ "Downloads", "data", "from", "url", "and", "makes", "changes", "to", "match", "the", "CSV", "format", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/census_dataset.py#L59-L73
[ "def", "_download_and_clean_file", "(", "filename", ",", "url", ")", ":", "temp_file", ",", "_", "=", "urllib", ".", "request", ".", "urlretrieve", "(", "url", ")", "with", "tf", ".", "gfile", ".", "Open", "(", "temp_file", ",", "'r'", ")", "as", "temp...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
download
Download census data if it is not already present.
examples/wide_deep/census_dataset.py
def download(data_dir): """Download census data if it is not already present.""" tf.gfile.MakeDirs(data_dir) training_file_path = os.path.join(data_dir, TRAINING_FILE) if not tf.gfile.Exists(training_file_path): _download_and_clean_file(training_file_path, TRAINING_URL) eval_file_path = os.path.join(dat...
def download(data_dir): """Download census data if it is not already present.""" tf.gfile.MakeDirs(data_dir) training_file_path = os.path.join(data_dir, TRAINING_FILE) if not tf.gfile.Exists(training_file_path): _download_and_clean_file(training_file_path, TRAINING_URL) eval_file_path = os.path.join(dat...
[ "Download", "census", "data", "if", "it", "is", "not", "already", "present", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/census_dataset.py#L76-L86
[ "def", "download", "(", "data_dir", ")", ":", "tf", ".", "gfile", ".", "MakeDirs", "(", "data_dir", ")", "training_file_path", "=", "os", ".", "path", ".", "join", "(", "data_dir", ",", "TRAINING_FILE", ")", "if", "not", "tf", ".", "gfile", ".", "Exist...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
build_model_columns
Builds a set of wide and deep feature columns.
examples/wide_deep/census_dataset.py
def build_model_columns(): """Builds a set of wide and deep feature columns.""" # Continuous variable columns age = tf.feature_column.numeric_column('age') education_num = tf.feature_column.numeric_column('education_num') capital_gain = tf.feature_column.numeric_column('capital_gain') capital_loss = tf.feat...
def build_model_columns(): """Builds a set of wide and deep feature columns.""" # Continuous variable columns age = tf.feature_column.numeric_column('age') education_num = tf.feature_column.numeric_column('education_num') capital_gain = tf.feature_column.numeric_column('capital_gain') capital_loss = tf.feat...
[ "Builds", "a", "set", "of", "wide", "and", "deep", "feature", "columns", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/census_dataset.py#L89-L157
[ "def", "build_model_columns", "(", ")", ":", "# Continuous variable columns", "age", "=", "tf", ".", "feature_column", ".", "numeric_column", "(", "'age'", ")", "education_num", "=", "tf", ".", "feature_column", ".", "numeric_column", "(", "'education_num'", ")", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
input_fn
Generate an input function for the Estimator.
examples/wide_deep/census_dataset.py
def input_fn(data_file, num_epochs, shuffle, batch_size): """Generate an input function for the Estimator.""" assert tf.gfile.Exists(data_file), ( '%s not found. Please make sure you have run census_dataset.py and ' 'set the --data_dir argument to the correct path.' % data_file) def parse_csv(value):...
def input_fn(data_file, num_epochs, shuffle, batch_size): """Generate an input function for the Estimator.""" assert tf.gfile.Exists(data_file), ( '%s not found. Please make sure you have run census_dataset.py and ' 'set the --data_dir argument to the correct path.' % data_file) def parse_csv(value):...
[ "Generate", "an", "input", "function", "for", "the", "Estimator", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/census_dataset.py#L160-L186
[ "def", "input_fn", "(", "data_file", ",", "num_epochs", ",", "shuffle", ",", "batch_size", ")", ":", "assert", "tf", ".", "gfile", ".", "Exists", "(", "data_file", ")", ",", "(", "'%s not found. Please make sure you have run census_dataset.py and '", "'set the --data_...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
MessageSocket.receive
Receive a message on ``sock``.
tensorflowonspark/reservation.py
def receive(self, sock): """Receive a message on ``sock``.""" msg = None data = b'' recv_done = False recv_len = -1 while not recv_done: buf = sock.recv(BUFSIZE) if buf is None or len(buf) == 0: raise Exception("socket closed") if recv_len == -1: recv_len = stru...
def receive(self, sock): """Receive a message on ``sock``.""" msg = None data = b'' recv_done = False recv_len = -1 while not recv_done: buf = sock.recv(BUFSIZE) if buf is None or len(buf) == 0: raise Exception("socket closed") if recv_len == -1: recv_len = stru...
[ "Receive", "a", "message", "on", "sock", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L69-L89
[ "def", "receive", "(", "self", ",", "sock", ")", ":", "msg", "=", "None", "data", "=", "b''", "recv_done", "=", "False", "recv_len", "=", "-", "1", "while", "not", "recv_done", ":", "buf", "=", "sock", ".", "recv", "(", "BUFSIZE", ")", "if", "buf",...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
MessageSocket.send
Send ``msg`` to destination ``sock``.
tensorflowonspark/reservation.py
def send(self, sock, msg): """Send ``msg`` to destination ``sock``.""" data = pickle.dumps(msg) buf = struct.pack('>I', len(data)) + data sock.sendall(buf)
def send(self, sock, msg): """Send ``msg`` to destination ``sock``.""" data = pickle.dumps(msg) buf = struct.pack('>I', len(data)) + data sock.sendall(buf)
[ "Send", "msg", "to", "destination", "sock", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L91-L95
[ "def", "send", "(", "self", ",", "sock", ",", "msg", ")", ":", "data", "=", "pickle", ".", "dumps", "(", "msg", ")", "buf", "=", "struct", ".", "pack", "(", "'>I'", ",", "len", "(", "data", ")", ")", "+", "data", "sock", ".", "sendall", "(", ...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
Server.await_reservations
Block until all reservations are received.
tensorflowonspark/reservation.py
def await_reservations(self, sc, status={}, timeout=600): """Block until all reservations are received.""" timespent = 0 while not self.reservations.done(): logging.info("waiting for {0} reservations".format(self.reservations.remaining())) # check status flags for any errors if 'error' in ...
def await_reservations(self, sc, status={}, timeout=600): """Block until all reservations are received.""" timespent = 0 while not self.reservations.done(): logging.info("waiting for {0} reservations".format(self.reservations.remaining())) # check status flags for any errors if 'error' in ...
[ "Block", "until", "all", "reservations", "are", "received", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L111-L126
[ "def", "await_reservations", "(", "self", ",", "sc", ",", "status", "=", "{", "}", ",", "timeout", "=", "600", ")", ":", "timespent", "=", "0", "while", "not", "self", ".", "reservations", ".", "done", "(", ")", ":", "logging", ".", "info", "(", "\...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
Server.start
Start listener in a background thread Returns: address of the Server as a tuple of (host, port)
tensorflowonspark/reservation.py
def start(self): """Start listener in a background thread Returns: address of the Server as a tuple of (host, port) """ server_sock = self.start_listening_socket() # hostname may not be resolvable but IP address probably will be host = self.get_server_ip() port = server_sock.getsockn...
def start(self): """Start listener in a background thread Returns: address of the Server as a tuple of (host, port) """ server_sock = self.start_listening_socket() # hostname may not be resolvable but IP address probably will be host = self.get_server_ip() port = server_sock.getsockn...
[ "Start", "listener", "in", "a", "background", "thread" ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L146-L186
[ "def", "start", "(", "self", ")", ":", "server_sock", "=", "self", ".", "start_listening_socket", "(", ")", "# hostname may not be resolvable but IP address probably will be", "host", "=", "self", ".", "get_server_ip", "(", ")", "port", "=", "server_sock", ".", "get...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c
train
Client._request
Helper function to wrap msg w/ msg_type.
tensorflowonspark/reservation.py
def _request(self, msg_type, msg_data=None): """Helper function to wrap msg w/ msg_type.""" msg = {} msg['type'] = msg_type if msg_data: msg['data'] = msg_data done = False tries = 0 while not done and tries < MAX_RETRIES: try: MessageSocket.send(self, self.sock, msg) ...
def _request(self, msg_type, msg_data=None): """Helper function to wrap msg w/ msg_type.""" msg = {} msg['type'] = msg_type if msg_data: msg['data'] = msg_data done = False tries = 0 while not done and tries < MAX_RETRIES: try: MessageSocket.send(self, self.sock, msg) ...
[ "Helper", "function", "to", "wrap", "msg", "w", "/", "msg_type", "." ]
yahoo/TensorFlowOnSpark
python
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L220-L245
[ "def", "_request", "(", "self", ",", "msg_type", ",", "msg_data", "=", "None", ")", ":", "msg", "=", "{", "}", "msg", "[", "'type'", "]", "=", "msg_type", "if", "msg_data", ":", "msg", "[", "'data'", "]", "=", "msg_data", "done", "=", "False", "tri...
5e4b6c185ab722fd0104ede0377e1149ea8d6f7c