Send histograms of parameters to tensorboard.
16850
def log_histograms(self, model: Model, histogram_parameters: Set[str]) -> None:
        
        for name, param in model.named_parameters():
            if name in histogram_parameters:
                self.add_train_histogram("parameter_histogram/" + name, param)
1077066
def provide_data(self):
        """"""
        return [(k, tuple([self.batch_size] + list(v.shape[1:]))) for k, v in self.data]
991743
def serialize_all(obj):
        """"""
        if '_hyperparameters' not in dir(obj):
            return {}
        return {k: str(v) for k, v in obj._hyperparameters.items() if v is not None}
974763
def get_xgb_params(self):
        """"""
        xgb_params = self.get_params()

        xgb_params['silent'] = 1 if self.silent else 0

        if self.nthread <= 0:
            xgb_params.pop('nthread', None)
        return xgb_params
957486
def export_fun(args):
  """"""
  # Input placeholder for inferencing
  x = tf.placeholder(tf.float32, [None, IMAGE_PIXELS * IMAGE_PIXELS], name="x")

  # Variables of the hidden layer
  hid_w = tf.Variable(tf.truncated_normal([IMAGE_PIXELS * IMAGE_PIXELS, hidden_units],
                      stddev=1.0 / IMAGE_PIXELS), name="hid_w")
  hid_b = tf.Variable(tf.zeros([hidden_units]), name="hid_b")
  tf.summary.histogram("hidden_weights", hid_w)

  # Variables of the softmax layer
  sm_w = tf.Variable(tf.truncated_normal([hidden_units, 10],
                     stddev=1.0 / math.sqrt(hidden_units)), name="sm_w")
  sm_b = tf.Variable(tf.zeros([10]), name="sm_b")

  hid_lin = tf.nn.xw_plus_b(x, hid_w, hid_b)
  hid = tf.nn.relu(hid_lin)
  y = tf.nn.softmax(tf.nn.xw_plus_b(hid, sm_w, sm_b))
  prediction = tf.argmax(y, 1, name="prediction")

  saver = tf.train.Saver()

  with tf.Session() as sess:
    # load graph from a checkpoint
    logging.info("model path: {}".format(args.model_dir))
    ckpt = tf.train.get_checkpoint_state(args.model_dir)
    logging.info("ckpt: {}".format(ckpt))
    assert ckpt and ckpt.model_checkpoint_path, "Invalid model checkpoint path: {}".format(args.model_dir)
    saver.restore(sess, ckpt.model_checkpoint_path)

    logging.info("Exporting saved_model to: {}".format(args.export_dir))
    # exported signatures defined in code
    signatures = {
      tf.saved_model.signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY: {
        'inputs': {'image': x},
        'outputs': {'prediction': prediction},
        'method_name': tf.saved_model.signature_constants.PREDICT_METHOD_NAME
      },
      'featurize': {
        'inputs': {'image': x},
        'outputs': {'features': hid},
        'method_name': 'featurize'
      }
    }
    TFNode.export_saved_model(sess,
                              args.export_dir,
                              tf.saved_model.tag_constants.SERVING,
                              signatures)
    logging.info("Exported saved_model")
596283
public static void histogram( GrayS8 input , int minValue , int histogram[] ) {
		if( BoofConcurrency.USE_CONCURRENT ) {
			ImplImageStatistics_MT.histogram(input,minValue,histogram);
		} else {
			ImplImageStatistics.histogram(input,minValue,histogram);
		}
	}
85490
def cmdline_params(self, surface_sample_file_name, cell_file_name):
        
        parameters = []

        parameters += [surface_sample_file_name]
        parameters += [cell_file_name]
        parameters += [self._OUTPUT_FILE_NAME]

        return map(str, parameters)
268367
def _send_textmetrics(metrics):
    '''
    
    '''

    data = [' '.join(map(six.text_type, metric)) for metric in metrics] + ['']

    return '\n'.join(data)
385345
def rippe_parameters(matrix, positions, lengths=None, init=None, circ=False):
    

    n, _ = matrix.shape

    if lengths is None:
        lengths = np.abs(np.diff(positions))

    measurements, bins = [], []
    for i in range(n):
        for j in range(1, i):
            mean_length = (lengths[i] + lengths[j]) / 2.
            if positions[i] < positions[j]:
                d = (((positions[j] - positions[i] -
                     lengths[i]) + mean_length) /
                     1000.)
            else:
                d = (((positions[i] - positions[j] -
                     lengths[j]) + mean_length) /
                     1000.)

            bins.append(np.abs(d))
            measurements.append(matrix[i, j])
    parameters = estimate_param_rippe(measurements, bins, init=init, circ=circ)
    print(parameters)
    return parameters[0]
224123
def _call(self, x):
        """"""
        result = self.sess.run(self.output_tensor,
                               feed_dict={self.input_tensor: np.asarray(x)})

        return result
639088
def write_bytes(self, data, n):
        """"""
        for pos in xrange(0, n):
            self.payload[self.pos + pos] = data[pos]
            
        self.pos += n
1160002
public static void histogram( GrayS64 input , long minValue , int histogram[] ) {
		if( BoofConcurrency.USE_CONCURRENT ) {
			ImplImageStatistics_MT.histogram(input,minValue,histogram);
		} else {
			ImplImageStatistics.histogram(input,minValue,histogram);
		}
	}
107109
def interp(net, layers):
    
    for l in layers:
        m, k, h, w = net.params[l][0].data.shape
        if m != k and k != 1:
            print 'input + output channels need to be the same or |output| == 1'
            raise
        if h != w:
            print 'filters need to be square'
            raise
        filt = upsample_filt(h)
        net.params[l][0].data[range(m), range(k), :, :] = filt
312880
def stream_tfevents(path, file_api, step=0):
    """"""
    last_step = 0
    row = {}
    buffer = []
    last_row = {}
    for summary in tf.train.summary_iterator(path):
        parsed = tf_summary_to_dict(summary)
        if last_step != parsed["tensorflow_step"]:
            step += 1
            last_step = parsed["tensorflow_step"]
            # TODO: handle time
            if len(row) > 0:
                last_row = to_json(row)
                buffer.append(Chunk("wandb-history.jsonl",
                                    util.json_dumps_safer_history(to_json(row))))
        row.update(parsed)
    file_api._send(buffer)
    return last_row
734735
def _send_picklemetrics(metrics):
    '''
    
    '''

    metrics = [(metric_name, (timestamp, value))
               for (metric_name, value, timestamp) in metrics]

    data = cPickle.dumps(metrics, -1)
    payload = struct.pack(b'!L', len(data)) + data

    return payload
899611
def _frombuffer(ptr, frames, channels, dtype):
    """"""
    framesize = channels * dtype.itemsize
    data = np.frombuffer(ffi.buffer(ptr, frames * framesize), dtype=dtype)
    data.shape = -1, channels
    return data
664298
def int_to_bit_embed(x_int, num_bits, embedding_size, base=2):
  """"""
  shape = common_layers.shape_list(x_int)
  inputs = int_to_bit(x_int, num_bits, base=base)
  inputs = tf.reshape(inputs, shape[:-1] + [shape[-1] * 8])
  inputs = 2.0 * tf.to_float(inputs) - 1.0  # Move from 0/1 to -1/1.
  return tf.layers.dense(inputs, embedding_size, name="int_to_bit_embed")