Writes model histograms to Tensorboard.
4221
def write(self)->None:
        ""
        for param_name, values in self.params: self._write_histogram(param_name=param_name, values=values)
923990
def _write_weight_histograms(self, iteration:int)->None:
        ""
        generator, critic = self.learn.gan_trainer.generator, self.learn.gan_trainer.critic
        self.hist_writer.write(model=generator, iteration=iteration, tbwriter=self.tbwriter, name='generator')
        self.hist_writer.write(model=critic,    iteration=iteration, tbwriter=self.tbwriter, name='critic')
1066709
public void dump_stats(Writer out, boolean labels)
    throws IOException
    {
        if ( labels ) {
            out.write("--------------------------------------------------\n");
            out.write("FileManager Header:\n");
            out.write("--------------------------------------------------\n");
            out.write("Filename = " + filename + "\n");
            out.write("Allocations: " + allocs + "\n");
            out.write("Deallocations: " + deallocs +"\n");
            out.write("Coalesces: " + coalesces + "\n");
            out.write("Allocated blocks: " + allocated_blocks + "\n");
            out.write("Allocated bytes: " + allocated_words +"\n");           
            out.write("Free blocks: " + free_blocks+ "\n");
            out.write("Free bytes: " + free_words+ "\n");
            out.write("Seeks: " + seeks+ "\n");
            out.write("Requests for small blocks: " + small_requests+ "\n");
            out.write("Requests for large blocks: " + large_requests+ "\n");
            out.write("Quick list hits: " + ql_hits+ "\n");
            out.write("Misc list hits: " + ml_hits+ "\n");
            out.write("Block splits (from misc list): " + ml_splits+ "\n");
            out.write("Misc list blocks searched: " + ml_blocks_searched+ "\n");
            out.write("Fast startups: " + fast_startups+ "\n");

            //out.write("Internal blocksize = " + CACHE_PAGESIZE + "\n");
            //out.write("Cache size = " + cachesize+ "\n");
            //out.write("Cache hits: " + cache_hits+ "\n");
            //out.write("Cache misses: " + cache_misses+ "\n");
            //out.write("Page allocations: " + page_allocations+ "\n");
            out.write("Read requests: " + read_count + "\n");
            out.write("Write requests: " + write_count+ "\n");
            out.write("Accumulated physical read time:" + read_time+ "\n");
            out.write("Accumulated physical write time:" + write_time+ "\n");
            out.write("Bytes read: " + bytes_read + "\n");
            out.write("Bytes written: " + bytes_written + "\n");
        } else {
            out.write(filename + "\t");
            out.write(allocs + "\t");
            out.write(deallocs +"\t");
            out.write(coalesces + "\t");
            out.write(allocated_blocks + "\t");
            out.write(allocated_words +"\t");           
            out.write(free_blocks+ "\t");
            out.write(free_words+ "\t");

            out.write(seeks+ "\t");
            out.write(read_count + "\t");
            out.write(write_count+ "\t");
            out.write(read_time+ "\t");
            out.write(write_time+ "\t");

            out.write(bytes_read + "\t");
            out.write(bytes_written + "\t");

            out.write(small_requests+ "\t");
            out.write(large_requests+ "\t");
            out.write(ql_hits+ "\t");
            out.write(ml_hits+ "\t");
            out.write(ml_splits+ "\t");
            out.write(ml_blocks_searched+ "\t");
            out.write(fast_startups+ "\t");

            //out.write(CACHE_PAGESIZE + "\t");
            //out.write(cachesize+ "\t");
            //out.write(cache_hits+ "\t");
            //out.write(cache_misses+ "\t");
            //out.write(page_allocations+ "\t");

        }
    }
1265724
def _write_for_dstype(self, learn:Learner, batch:Tuple, iteration:int, tbwriter:SummaryWriter, ds_type:DatasetType)->None:
        ""
        request = ImageTBRequest(learn=learn, batch=batch, iteration=iteration, tbwriter=tbwriter, ds_type=ds_type)
        asyncTBWriter.request_write(request)
937478
def write(models, csvout, rulelist, write_header, base=None, logger=logging):
    '''
    
    '''
    properties = [ k for (k, v) in rulelist ]
    numprops = len(properties)
    headers = [ v for (k, v) in rulelist ]
    if write_header:
        csvout.writerow(['id', 'type'] + headers)

    rules = { k: v for (k, v) in rulelist }

    if not isinstance(models, list): models = [models]
    for m in models:
        mapped = omap(m)
        for o, props in mapped.items():
            rtypes = list(map(operator.itemgetter(0), props.get(RDF_TYPE_REL, [])))
            if not rtypes: continue
            #print('RES TYPES:', rtypes)
            row = [o, fromlist(rtypes)] + [None] * numprops
            for ix, p in enumerate(properties):
                v = list(map(operator.itemgetter(0), props.get(p, [])))
                if v:
                    row[ix + 2] = fromlist(v)
                    csvout.writerow(row)

    return
502987
public void writeByteBufferSparse(ByteBuffer buf, int nonEmptyBuckets)
  {
    writeByteBufferSerdeHeader(buf, SPARSE_ENCODING_MODE);
    writeByteBufferCommonFields(buf);

    buf.putInt(nonEmptyBuckets);
    int bucketsWritten = 0;
    for (int i = 0; i < numBuckets; i++) {
      if (histogram[i] > 0) {
        buf.putInt(i);
        buf.putLong(histogram[i]);
        bucketsWritten += 1;
      }
      if (bucketsWritten == nonEmptyBuckets) {
        break;
      }
    }
  }
1016840
def model_sizes(m:nn.Module, size:tuple=(64,64))->Tuple[Sizes,Tensor,Hooks]:
    ""
    with hook_outputs(m) as hooks:
        x = dummy_eval(m, size)
        return [o.stored.shape for o in hooks]
1043742
def write_dataframe(self, result, dst_paths, nodata=None, compress='lzw'):
        """"""
        result = self._convert_to_ndarray(result)
        self.write_ndarray(result, dst_paths, nodata=nodata, compress=compress)
793815
def writeWarp(self, warpDict):
        
        warpElement = ET.Element("warp")
        axisNames = sorted(warpDict.keys())
        for name in axisNames:
            axisElement = ET.Element("axis")
            axisElement.attrib['name'] = name
            for a, b in warpDict[name]:
                warpPt = ET.Element("map")
                warpPt.attrib['input'] = str(a)
                warpPt.attrib['output'] = str(b)
                axisElement.append(warpPt)
            warpElement.append(axisElement)
        self.root.append(warpElement)
1131133
def save_model(proto, f, format=None):  # type: (Union[ModelProto, bytes], Union[IO[bytes], Text], Optional[Any]) -> None
    '''
    
    '''
    if isinstance(proto, bytes):
        proto = _deserialize(proto, ModelProto())

    model_filepath = _get_file_path(f)
    if model_filepath:
        basepath = os.path.dirname(model_filepath)
        proto = write_external_data_tensors(proto, basepath)

    s = _serialize(proto)
    _save_bytes(s, f)
136952
def write_data(self, output):
        
        if self.figure:
            canvas = FigureCanvas(self.figure)
            self.figure.savefig(output, format='png', bbox_inches='tight')
            output.seek(0)
            return output.getvalue()
        return None
141241
def create_model_tar(matrices, tarname="model-cuda-converted.tar"):
    
    # Write layers
    filenames = []
    for layer in range(len(matrices)):
        if matrices[layer]['name'] == 'W':
            weights = matrices[layer]['storage']
            weights_file = h5py.File('W%i.hdf5' % (layer / 2), 'w')
            weights_file.create_dataset(weights_file.id.name, data=weights)
            weights_file.close()
            filenames.append('W%i.hdf5' % (layer / 2))
        elif matrices[layer]['name'] == 'b':
            b = matrices[layer]['storage']
            bfile = h5py.File('b%i.hdf5' % (layer / 2), 'w')
            bfile.create_dataset(bfile.id.name, data=b)
            bfile.close()
            filenames.append('b%i.hdf5' % (layer / 2))

        # activation = a['layers'][layer]['_props']['activation']
        # activation = activation.replace('sigmoid', 'Sigmoid')
        # activation = activation.replace('softmax', 'Softmax')
        # layers.append({'W': {'size': list(W.shape),
        #                      'filename': 'W%i.hdf5' % layer},
        #                'b': {'size': list(b.shape),
        #                      'filename': 'b%i.hdf5' % layer},
        #                'activation': activation})
    with tarfile.open(tarname, "w:") as tar:
        for name in filenames:
            tar.add(name)

    # Remove temporary files which are now in tar file
    for filename in filenames:
        os.remove(filename)
906196
def write(self, *messages):
        """"""

        for i in self.graph.outputs_of(BEGIN):
            for message in messages:
                self[i].write(message)
1096207
def convert_predictions_to_image_summaries(hook_args):
  
  decode_hparams = hook_args.decode_hparams
  if not decode_hparams.display_decoded_images:
    return []
  predictions = hook_args.predictions[0]

  # Display ten random inputs and outputs so that tensorboard does not hang.
  all_summaries = []
  rand_predictions = np.random.choice(predictions, size=10)
  for ind, prediction in enumerate(rand_predictions):
    output_summary = image_to_tf_summary_value(
        prediction["outputs"], tag="%d_output" % ind)
    input_summary = image_to_tf_summary_value(
        prediction["inputs"], tag="%d_input" % ind)
    all_summaries.append(input_summary)
    all_summaries.append(output_summary)
  return all_summaries
344245
def histogram2d(data1, data2, bins=None, *args, **kwargs):
    """"""
    # TODO: currently very unoptimized! for non-dasks
    import dask
    if "axis_names" not in kwargs:
        if hasattr(data1, "name") and hasattr(data2, "name"):
            kwargs["axis_names"] = [data1.name, data2.name]
    if not hasattr(data1, "dask"):
        data1 = dask.array.from_array(data1, chunks=data1.size() / 100)
    if not hasattr(data2, "dask"):
        data2 = dask.array.from_array(data2, chunks=data2.size() / 100)

    data = dask.array.stack([data1, data2], axis=1)
    kwargs["dim"] = 2
    return histogramdd(data, bins, *args, **kwargs)
758955
def produce_csv(input, output):
    
    '''
    output.write('"model","mean","std"\n')
    for model_data in input:
        output.write('"%s",%f,%f\n' % (model_data['name'], model_data['mean'], model_data['stddev']))
    output.flush()
    output.close()
    print("Wrote as %s" % output.name)
1212385
def _write_critic_model_stats(self, iteration:int)->None:
        ""
        critic = self.learn.gan_trainer.critic
        self.stats_writer.write(model=critic, iteration=iteration, tbwriter=self.tbwriter, name='crit_model_stats')
        self.crit_stats_updated = True