标签:git hub new t 一段 tensor int apple box 身高
fb官方的一些demo
1. vis.image:显示一张图片
viz.image( np.random.rand(3, 512, 256), opts=dict(title=‘Random!‘, caption=‘How random.‘), )
opts.jpgquality
:JPG
质量(number0-100
;默认= 100
)opts.caption
:图像的标题
2. vis.images:显示一组图片
viz.images( np.random.randn(20, 3, 64, 64), opts=dict(title=‘Random images‘, caption=‘How random.‘) )
输入类型:B x C x H x W
张量或list of images
全部相同的大小。它使大小的图像(B / Nrow,Nrow
)的网格。 可选参数opts:
nrow
:连续的图像数量padding
:在图像周围填充,四边均匀填充opts.jpgquality
:JPG
质量(number0-100;
默认= 100
)opts.caption
:图像的标题
3. vis.text:显示一段文本
viz.text(‘Hello World !)
4. viz.video:显示一段视频
video = np.empty([256, 250, 250, 3], dtype=np.uint8) for n in range(256): video[n, :, :, :].fill(n) viz.video(tensor=video)
1. vis.scatter :绘制2D或3D散点图
Y = np.random.rand(100) old_scatter = viz.scatter( # 新开一个scatter窗口 X=np.random.rand(100, 2), Y=(Y[Y > 0] + 1.5).astype(int), opts=dict( legend=[‘Didnt‘, ‘Update‘], xtickmin=-50, xtickmax=50, xtickstep=0.5, ytickmin=-50, ytickmax=50, ytickstep=0.5, markersymbol=‘cross-thin-open‘, ), ) viz.update_window_opts( win=old_scatter, # 更新窗口 opts=dict( legend=[‘Apples‘, ‘Pears‘], xtickmin=0, xtickmax=1, xtickstep=0.5, ytickmin=0, ytickmax=1, ytickstep=0.5, markersymbol=‘cross-thin-open‘, ), )
opts.markercolor是一个整数值的张量。张量可以是大小N或N x 3或K或K x 3。
可以在visdom界面上直接保存png格式
又如右上图:
viz.scatter( X=np.random.rand(100, 3), Y=(Y + 1.5).astype(int), opts=dict( legend=[‘Men‘, ‘Women‘], markersize=5, ) )
定制点类型、强度、颜色、文字:
viz.scatter( X=np.random.rand(255, 2), Y=(np.random.randn(255) > 0) + 1, opts=dict( markersize=10, markercolor=np.floor(np.random.random((2, 3)) * 255), ), ) win = viz.scatter( X=np.random.rand(255, 2), opts=dict( markersize=10, markercolor=np.random.randint(0, 255, (255, 3,)), ), ) # assert that the window exists assert viz.win_exists(win), ‘Created window marked as not existing‘ # add new trace to scatter plot viz.scatter( X=np.random.rand(255), Y=np.random.rand(255), win=win, name=‘new_trace‘, update=‘new‘ ) # 2D scatter plot with text labels: viz.scatter( X=np.random.rand(10, 2), opts=dict( textlabels=[‘Label %d‘ % (i + 1) for i in range(10)] ) )
效果如下:
2. viz.bar: 绘制规则的,堆积的或分组的条形图
viz.bar(X=np.random.rand(20)) viz.bar( X=np.abs(np.random.rand(5, 3)), opts=dict( stacked=True, legend=[‘Facebook‘, ‘Google‘, ‘Twitter‘], rownames=[‘2012‘, ‘2013‘, ‘2014‘, ‘2015‘, ‘2016‘] ) ) viz.bar( X=np.random.rand(20, 3), opts=dict( stacked=False, legend=[‘The Netherlands‘, ‘France‘, ‘United States‘] ) )
可选参数:
效果如下:
3 viz.histogram: 绘制直方图
viz.histogram(X=np.random.rand(10000), opts=dict(numbins=20))
可选参数:
4. viz.heatmap:绘制热图
viz.heatmap( X=np.outer(np.arange(1, 6), np.arange(1, 11)), opts=dict( columnnames=[‘a‘, ‘b‘, ‘c‘, ‘d‘, ‘e‘, ‘f‘, ‘g‘, ‘h‘, ‘i‘, ‘j‘], rownames=[‘y1‘, ‘y2‘, ‘y3‘, ‘y4‘, ‘y5‘], colormap=‘Electric‘, ) )
可选参数:
5. viz.contour:绘制等高线
x = np.tile(np.arange(1, 101), (100, 1)) y = x.transpose() X = np.exp((((x - 50) ** 2) + ((y - 50) ** 2)) / -(20.0 ** 2)) viz.contour(X=X, opts=dict(colormap=‘Viridis‘))
可选参数:
6. vis.surf :绘制曲面图
viz.surf(X=X, opts=dict(colormap=‘Hot‘))
可选参数:
7. vis.boxplot:绘制箱型图
X = np.random.rand(100, 2) X[:, 1] += 2 viz.boxplot( X=X, opts=dict(legend=[‘Men‘, ‘Women‘]) )
可选参数:
8. vis.stem:绘制杆图
Y = np.linspace(0, 2 * math.pi, 70) X = np.column_stack((np.sin(Y), np.cos(Y))) viz.stem( X=X, Y=Y, opts=dict(legend=[‘Sine‘, ‘Cosine‘]) )
可选参数:
直方图至杆图实例:(左至右,上至下)
9. viz.quiver:绘制矢量场
X = np.arange(0, 2.1, .2) Y = np.arange(0, 2.1, .2) X = np.broadcast_to(np.expand_dims(X, axis=1), (len(X), len(X))) Y = np.broadcast_to(np.expand_dims(Y, axis=0), (len(Y), len(Y))) U = np.multiply(np.cos(X), Y) V = np.multiply(np.sin(X), Y) viz.quiver( X=U, Y=V, opts=dict(normalize=0.9), )
10. viz.pie:绘制饼图
X = np.asarray([19, 26, 55]) viz.pie( X=X, opts=dict(legend=[‘Residential‘, ‘Non-Residential‘, ‘Utility‘]) )
11. viz.mesh:绘制网格图
x = [0, 0, 1, 1, 0, 0, 1, 1] y = [0, 1, 1, 0, 0, 1, 1, 0] z = [0, 0, 0, 0, 1, 1, 1, 1] X = np.c_[x, y, z] i = [7, 0, 0, 0, 4, 4, 6, 6, 4, 0, 3, 2] j = [3, 4, 1, 2, 5, 6, 5, 2, 0, 1, 6, 3] k = [0, 7, 2, 3, 6, 7, 1, 1, 5, 5, 7, 6] Y = np.c_[i, j, k] viz.mesh(X=X, Y=Y, opts=dict(opacity=0.5))
可选参数:
矢量场至网格图实例:(左至右,上至下)
12. vis.line:绘制线条
viz.line(Y=np.random.rand(10), opts=dict(showlegend=True)) Y = np.linspace(-5, 5, 100) viz.line( Y=np.column_stack((Y * Y, np.sqrt(Y + 5))), X=np.column_stack((Y, Y)), opts=dict(markers=False), )
可选参数:
更新可选参数:
# line updates win = viz.line( X=np.column_stack((np.arange(0, 10), np.arange(0, 10))), Y=np.column_stack((np.linspace(5, 10, 10), np.linspace(5, 10, 10) + 5)), ) viz.line( X=np.column_stack((np.arange(10, 20), np.arange(10, 20))), Y=np.column_stack((np.linspace(5, 10, 10), np.linspace(5, 10, 10) + 5)), win=win, update=‘append‘ ) viz.line( X=np.arange(21, 30), Y=np.arange(1, 10), win=win, name=‘2‘, update=‘append‘ ) viz.line( X=np.arange(1, 10), Y=np.arange(11, 20), win=win, name=‘delete this‘, update=‘append‘ ) viz.line( X=np.arange(1, 10), Y=np.arange(11, 20), win=win, name=‘4‘, update=‘insert‘ )
附:通用可选参数:
标签:git hub new t 一段 tensor int apple box 身高
原文地址:https://www.cnblogs.com/king-lps/p/8973824.html