from torch.utils.tensorboard import SummaryWriter writer = SummaryWriter() r = 5 for i inrange(100): writer.add_scalars('run_14h', {'xsinx':i*np.sin(i/r), 'xcosx':i*np.cos(i/r), 'tanx': np.tan(i/r)}, i) writer.close() # This call adds three values to the same scalar plot with the tag # 'run_14h' in TensorBoard's scalar section.
model (torch.nn.Module) – Model to draw. input_to_model (torch.Tensor orlist of torch.Tensor) – A variable or a tuple of variables to be fed. verbose (bool) – Whether to print graph structure in console. use_strict_trace (bool) – Whether to pass keyword argument strict to torch.jit.trace. Pass False when you want the tracer to record your mutable container types (list, dict)
mat (torch.Tensor or numpy.ndarray) – A matrix which each row is the feature vector of the data point metadata (list) – A list of labels, each element will be convert to string label_img (torch.Tensor) – Images correspond to each data point global_step (int) – Global step value to record tag (str) – Name for the embedding
示例代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import keyword import torch meta = [] whilelen(meta)<100: meta = meta+keyword.kwlist # get some strings meta = meta[:100]
for i, v inenumerate(meta): meta[i] = v+str(i)
label_img = torch.rand(100, 3, 10, 32) for i inrange(100): label_img[i]*=i/100.0