/usr/local/lib64/python3.6/site-packages/torch/utils/tensorboard/__pycache__
NameSizeModeActions
summary.cpython-36.pyc221990644editdlrm
writer.cpython-36.pyc426680644editdlrm
_caffe2_graph.cpython-36.pyc249570644editdlrm
_convert_np.cpython-36.pyc11470644editdlrm
_embedding.cpython-36.pyc32000644editdlrm
_onnx_graph.cpython-36.pyc18870644editdlrm
_proto_graph.cpython-36.pyc18550644editdlrm
_pytorch_graph.cpython-36.pyc100520644editdlrm
_utils.cpython-36.pyc43090644editdlrm
__init__.cpython-36.pyc5700644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/utils/tensorboard/__pycache__/summary.cpython-36.pyc (22199B)
3 EgRt@sddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl m Z ddl mZddlmZdd lmZdd lmZdd lmZdd lmZd dlmZd dlmZmZddZdDddZdEddZ dFddZ!ddZ"dGddZ#dHdd Z$dId"d#Z%dJd%d&Z&dKd'd(Z'dLd)d*Z(dMd,d-Z)d.d/Z*dNd1d2Z+d3d4Z,d5d6Z-dOd8d9Z.dPd:d;Z/dQdd?Z1d@dAZ2dRdBdCZ3dS)SN)Optional)range) struct_pb2)Summary)HistogramProto)SummaryMetadata) TensorProto)TensorShapeProto)TextPluginData)PrCurvePluginData) layout_pb2)make_np)_prepare_videoconvert_to_HWCcCs,t|tjs|jn|}|jtjkr(dSdS)Nr ) isinstancenpZndarraynumpydtypeuint8)tensorZ convertedrK/usr/local/lib64/python3.6/site-packages/torch/utils/tensorboard/summary.py_calc_scale_factorsrblackc Csddlm} m} | j} | j|} ||||f\} }}}| j| |f| |f||f||f| |fg||d|r|}| j|\}}tjd|}| j | ||d|f| ||fg|d| j | ||||f||| d|S)Nr) ImageDraw ImageFont)widthfillg?r)r )r font) PILrrZ load_defaultZDrawlinegetsizerceilZ rectangletext)imageZxminZyminZxmaxZymax display_strcolorZ color_textZ thicknessrrr!ZdrawleftrighttopZbottomZ text_bottom text_widthZ text_heightmarginrrr_draw_single_boxs"  r/csddl}ddlm}ddlm}m}mmm}m }ddl m } m } m } m} m} ddlm}m}m}ttstjdtdt|tstjdtd|pi}t|tstd xR|jD]F\}kst|t stfd d |D rtd jqWg}|}xjD]\}|dkr8q t|tsPt|tr||j_ |krt!j"d d|Dd}nd}|j#||j$d|dq t||r||j_%|krt!j"dd|Dd}nd}|j#||j$d|dq t|t&rd||j_'|krBt!j"dd|Dd}nd}|j#||j$d|dq t||j(rt)|d}||j_ |j#||j$ddq t*dq W||| d}t+t+j,| |j-dd}t.t.j$| |dgd}fdd|j/D}|||d}||| d}t+t+j,| |j-dd}t.t.j$| |dgd}||j$d d!}||| d"}t+t+j,| |j-dd}t.t.j$| |dgd}|||fS)#a2Outputs three `Summary` protocol buffers needed by hparams plugin. `Experiment` keeps the metadata of an experiment, such as the name of the hyperparameters and the name of the metrics. `SessionStartInfo` keeps key-value pairs of the hyperparameters `SessionEndInfo` describes status of the experiment e.g. STATUS_SUCCESS Args: hparam_dict: A dictionary that contains names of the hyperparameters and their values. metric_dict: A dictionary that contains names of the metrics and their values. hparam_domain_discrete: (Optional[Dict[str, List[Any]]]) A dictionary that contains names of the hyperparameters and all discrete values they can hold Returns: The `Summary` protobufs for Experiment, SessionStartInfo and SessionEndInfo rN) string_types) Experiment HParamInfo MetricInfo MetricNameStatusDataType) PLUGIN_NAMEPLUGIN_DATA_VERSIONEXPERIMENT_TAGSESSION_START_INFO_TAGSESSION_END_INFO_TAG)HParamsPluginDataSessionEndInfoSessionStartInfoz>parameter: hparam_dict should be a dictionary, nothing logged.z>parameter: metric_dict should be a dictionary, nothing logged.zIparameter: hparam_domain_discrete should be a dictionary, nothing logged.c3s |]}t|tVqdS)N)rtype).0d) hparam_dictkrr oszhparams..zWparameter: hparam_domain_discrete[{}] should be a list of same type as hparam_dict[{}].cSsg|]}tj|dqS)) number_value)rValue)r@rArrr szhparams..)valuesZDATA_TYPE_FLOAT64)namer?domain_discretecSsg|]}tj|dqS)) string_value)rrF)r@rArrrrGsZDATA_TYPE_STRINGcSsg|]}tj|dqS)) bool_value)rrF)r@rArrrrGsZDATA_TYPE_BOOL)rIr?z=value should be one of int, float, str, bool, or torch.Tensor)Zsession_start_infoversion) plugin_namecontent) plugin_data)tagmetadata)valuecsg|]}|ddqS))rQ)rIr)r@rC)r3r4rrrGs)Z hparam_infosZ metric_infos)Z experimentrMZSTATUS_SUCCESS)status)Zsession_end_inforM)0torchsixr0Z#tensorboard.plugins.hparams.api_pb2r1r2r3r4r5r6Z$tensorboard.plugins.hparams.metadatar7r8r9r:r;Z+tensorboard.plugins.hparams.plugin_data_pb2r<r=r>rdictloggingwarning TypeErroritemslistallformatintfloathparamsrErZ ListValueappendrFrKboolrLZTensorr ValueErrorr PluginDataSerializeToStringrkeys)rBZ metric_dictZhparam_domain_discreterUr0r1r2r5r6r7r8r9r:r;r<r=r>vZhpsZssirJrOsmdZmtsexpZseir)r3r4rBrCrra3s                         raFcCst|}|jjdkstdt|}|rxt|gdd}|rJt|gdd}tjdd}t|d }ttj |||d gd Sttj ||d gd Sd S)aOutputs a `Summary` protocol buffer containing a single scalar value. The generated Summary has a Tensor.proto containing the input Tensor. Args: name: A name for the generated node. Will also serve as the series name in TensorBoard. tensor: A real numeric Tensor containing a single value. collections: Optional list of graph collections keys. The new summary op is added to these collections. Defaults to `[GraphKeys.SUMMARIES]`. new_style: Whether to use new style (tensor field) or old style (simple_value field). New style could lead to faster data loading. Returns: A scalar `Tensor` of type `string`. Which contains a `Summary` protobuf. Raises: ValueError: If tensor has the wrong shape or type. rzscalar should be 0DDT_FLOAT) float_valrZ DT_DOUBLE)Z double_valrZscalars)rN)rP)rQrrR)rS)rQZ simple_valueN) rsqueezendimAssertionErrorr`rrrerrF)rIscalar collectionsZ new_styleZdouble_precisionrrPrirrrrps  rpc Cs,t|||||||d}ttj||dgdS)aOutputs a `Summary` protocol buffer with a histogram. The generated [`Summary`](https://www.tensorflow.org/code/tensorflow/core/framework/summary.proto) has one summary value containing a histogram for `values`. Args: name: A name for the generated node. Will also serve as a series name in TensorBoard. min: A float or int min value max: A float or int max value num: Int number of values sum: Float or int sum of all values sum_squares: Float or int sum of squares for all values bucket_limits: A numeric `Tensor` with upper value per bucket bucket_counts: A numeric `Tensor` with number of values per bucket Returns: A scalar `Tensor` of type `string`. The serialized `Summary` protocol buffer. )minmaxnumsum sum_squares bucket_limitbucket)rQhisto)rS)rrrF) rIrrrsrtrurvZ bucket_limitsZ bucket_countshistrrr histogram_rawsr{cCs0t|}t|jt||}ttj||dgdS)adOutputs a `Summary` protocol buffer with a histogram. The generated [`Summary`](https://www.tensorflow.org/code/tensorflow/core/framework/summary.proto) has one summary value containing a histogram for `values`. This op reports an `InvalidArgument` error if any value is not finite. Args: name: A name for the generated node. Will also serve as a series name in TensorBoard. values: A real numeric `Tensor`. Any shape. Values to use to build the histogram. Returns: A scalar `Tensor` of type `string`. The serialized `Summary` protocol buffer. )rQry)rS)rmake_histogramastyper`rrF)rIrHbinsmax_binsrzrrr histogram/src Cs|jdkrtd|jd}tj||d\}}t|}|dk r||kr||}||}|dkrztj|d||ggddd}|jd|jdd}tj|jdf|j }|dd||dd<|d|d<|}tj tj |dtj d } tj | d| ddgd d \} } t| } t| d} ~ | dkr2|| d| ntjdg|d| g}|| | d}|jdksr|jdkrztd |j|} t|j|jt||j| |j|jd S)zDConvert values into a histogram proto using logic from histogram.cc.rzThe input has no element.r )r~NZconstant)Z pad_widthmodeZconstant_values)Zaxis)rr+)Zsidez1The histogram is empty, please file a bug report.)rrrsrtrurvrwrxrrrrrrr)sizerdreshaperrlenpadruemptyrcumsumZgreaterint32Z searchsortedr_Z concatenatedotrrrrstolist) rHr~rcountsZlimitsZnum_binsZ subsamplingZsubsampling_remainderZ new_limitsZ cum_countsstartendZsum_sqrrrr|DsB      2 r|NCHWcCsXt|}t||}t|}|jtj}||jtj}t||d}ttj ||dgdS)aOutputs a `Summary` protocol buffer with images. The summary has up to `max_images` summary values containing images. The images are built from `tensor` which must be 3-D with shape `[height, width, channels]` and where `channels` can be: * 1: `tensor` is interpreted as Grayscale. * 3: `tensor` is interpreted as RGB. * 4: `tensor` is interpreted as RGBA. The `name` in the outputted Summary.Value protobufs is generated based on the name, with a suffix depending on the max_outputs setting: * If `max_outputs` is 1, the summary value tag is '*name*/image'. * If `max_outputs` is greater than 1, the summary value tags are generated sequentially as '*name*/image/0', '*name*/image/1', etc. Args: tag: A name for the generated node. Will also serve as a series name in TensorBoard. tensor: A 3-D `uint8` or `float32` `Tensor` of shape `[height, width, channels]` where `channels` is 1, 3, or 4. 'tensor' can either have values in [0, 1] (float32) or [0, 255] (uint8). The image() function will scale the image values to [0, 255] by applying a scale factor of either 1 (uint8) or 255 (float32). Returns: A scalar `Tensor` of type `string`. The serialized `Summary` protocol buffer. )rescale)rQr')rS) rrrr}rfloat32r make_imagerrF)rQrr dataformats scale_factorr'rrrr'rs   r'CHWcCs\t|}t||}t|}|jtjt|}t|jtj|||d}ttj ||dgdS)z0Outputs a `Summary` protocol buffer with images.)rroislabels)rQr')rS) rrr}rrrrrrrF)rQZ tensor_imageZ tensor_boxesrrrr'rrr image_boxess  rc Csj|jd}t|}xR|D]J}t|||df||df||df||df|dkrTdn||dd}qW|S)Nrr rZRed)r(r))shaperr/)Z disp_imageZboxesrZ num_boxesZlist_gtirrr draw_boxess       rcCsddlm}|j\}}}t||}t||} |j|} |dk rPt| ||d} | j| |f|j} ddl} | j } | j | dd| j } | j t j|||| dS)zg?r r)r~rrrrrr) rrfloorr}Zfloat64rrmaximumr)rrrrZ_MINIMUM_COUNTZbucket_indicesZ float_labelsZhistogram_rangeZ tp_buckets_Z fp_bucketsrrrrrrrrrr\s.    rc Csddl}ddlm}|j|}|j|||||j||d} td|jd jt t j |jddt j |jddt j |jddgd d }t j |j |||| d } | S) aCreates a tensor summary with summary metadata. Args: name: Uniquely identifiable name of the summary op. Could be replaced by combination of name and type to make it unique even outside of this summary. display_name: Will be used as the display name in TensorBoard. Defaults to `name`. description: A longform readable description of the summary data. Markdown is supported. tensor: Tensor to display in summary. content_type: Type of content inside the Tensor. components: Bitmask representing present parts (vertices, colors, etc.) that belong to the summary. json_config: A string, JSON-serialized dictionary of ThreeJS classes configuration. Returns: Tensor summary with metadata. rN)rR) json_configrkr )rr)r)rrlr)rQrrRr)rUtensorboard.plugins.meshrRZ as_tensorZcreate_summary_metadatarrrrr rrrFZget_instance_name) rI display_name descriptionrr componentsrrUrRZtensor_metadataZtensor_summaryrrr_get_tensor_summary{s,    rcCsd}|dk rtj|dd}|S)z6Parses and returns JSON string from python dictionary.z{}NT) sort_keys)jsondumps) config_dictrrrr_get_json_configsrc Csddlm}ddlm}t|} g} ||jf||jf||jfg} dd| D} |jdd| D} x*| D]"\} }| j t |||| || | qhWt | dS)aHOutputs a merged `Summary` protocol buffer with a mesh/point cloud. Args: tag: A name for this summary operation. vertices: Tensor of shape `[dim_1, ..., dim_n, 3]` representing the 3D coordinates of vertices. faces: Tensor of shape `[dim_1, ..., dim_n, 3]` containing indices of vertices within each triangle. colors: Tensor of shape `[dim_1, ..., dim_n, 3]` containing colors for each vertex. display_name: If set, will be used as the display name in TensorBoard. Defaults to `name`. description: A longform readable description of the summary data. Markdown is supported. config_dict: Dictionary with ThreeJS classes names and configuration. Returns: Merged summary for mesh/point cloud representation. r)MeshPluginData)rRcSsg|]}|ddk r|qS)rNr)r@rrrrrGszmesh..cSsg|] \}}|qSrr)r@rrrrrrGs)rS) Z(tensorboard.plugins.mesh.plugin_data_pb2rrrRrZVERTEXZFACEZCOLORZget_components_bitmaskrbrr)rQZverticescolorsZfacesrrrrrRrZ summariesZtensorsrrrrrrmeshs    r)rrr)NNN)NFF)N)N)r r)r rN)N)r NN)r)r)rN)rN)NN)NN)4rrXrrrtypingrZ six.movesrZgoogle.protobufrZ$tensorboard.compat.proto.summary_pb2rrrZ#tensorboard.compat.proto.tensor_pb2rZ)tensorboard.compat.proto.tensor_shape_pb2r Z(tensorboard.plugins.text.plugin_data_pb2r Z,tensorboard.plugins.pr_curve.plugin_data_pb2r Z!tensorboard.plugins.custom_scalarr Z _convert_npr_utilsrrrr/rarpr{rr|r'rrrrrrrr&rrrrrrrrrrsN              7 (  . #    '    4