当前位置:   article > 正文

深度学习框架 Digits 3.0 安装运行_if images.ndim == 3:

if images.ndim == 3:

NVIDIA 不愧是推动Deep learning 的中坚力量,之前运行2.0版本正得心应手时,就推出了3.0 版本。Github地址:https://github.com/NVIDIA/DIGITS,3.0版本的安装使用更为简洁,极易上手。

更新内容:

The new DIGITS 3 release improves training productivity with enhanced workflows.

  • Train neural network models with Torch support (preview), including pre-built AlexNet and GoogleNet models that make it easy to get started.
  • Quickly identify the best model through focused design iteration using the new results browser.
  • Easily manage multiple training jobs to optimize use of system resources.
  • Explore image datasets using the new dataset browser contributed to the DIGITS open source project by Deepomatic.
操作系统: Ubuntu 14.04 64bit.
首先需要配置Caffe 没有配置的同学自行官网。

命令行:
CUDA_REPO_PKG=cuda-repo-ubuntu1404_7.5-18_amd64.deb &&
    wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/$CUDA_REPO_PKG &&
    sudo dpkg -i $CUDA_REPO_PKG

ML_REPO_PKG=nvidia-machine-learning-repo_4.0-2_amd64.deb &&
    wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1404/x86_64/$ML_REPO_PKG &&
    sudo dpkg -i $ML_REPO_PKG
待添加完后同样命令行:
apt-get update
apt-get install digits
泡杯Caffe,然后等待安装完成。

安装完成后,在浏览器中输入:
http://localhost/
就可以见到亲切的DIGITS界面了,然后进行train吧。

PS:DIGITS开机自启动,同在一个局域网的机器也可以远程操作。同样在浏览器中输入 运行DIGITS的主机IP地址,同样进入。Amazing~

  1. def vis_square(images,
  2. padsize=1,
  3. normalize=False,
  4. colormap='jet',
  5. ):
  6. """
  7. Visualize each image in a grid of size approx sqrt(n) by sqrt(n)
  8. Returns a np.array image
  9. (Based on Caffe's filter_visualization notebook)
  10. Arguments:
  11. images -- an array of shape (N, H, W) or (N, H, W, C)
  12. if C is not set, a heatmap is computed for the result
  13. Keyword arguments:
  14. padsize -- how many pixels go inbetween the tiles
  15. normalize -- if true, scales (min, max) across all images out to (0, 1)
  16. colormap -- a string representing one of the suppoted colormaps
  17. """
  18. assert 3 <= images.ndim <= 4, 'images.ndim must be 3 or 4'
  19. # convert to float since we're going to do some math
  20. images = images.astype('float32')
  21. if normalize:
  22. images -= images.min()
  23. if images.max() > 0:
  24. images /= images.max()
  25. images *= 255
  26. if images.ndim == 3:
  27. # they're grayscale - convert to a colormap
  28. redmap, greenmap, bluemap = get_color_map(colormap)
  29. red = np.interp(images*(len(redmap)-1)/255.0, xrange(len(redmap)), redmap)
  30. green = np.interp(images*(len(greenmap)-1)/255.0, xrange(len(greenmap)), greenmap)
  31. blue = np.interp(images*(len(bluemap)-1)/255.0, xrange(len(bluemap)), bluemap)
  32. # Slap the channels back together
  33. images = np.concatenate( (red[...,np.newaxis], green[...,np.newaxis], blue[...,np.newaxis]), axis=3 )
  34. images = np.minimum(images,255)
  35. images = np.maximum(images,0)
  36. # convert back to uint8
  37. images = images.astype('uint8')
  38. # Compute the output image matrix dimensions
  39. n = int(np.ceil(np.sqrt(images.shape[0])))
  40. ny = n
  41. nx = n
  42. length = images.shape[0]
  43. if n*(n-1) >= length:
  44. nx = n-1
  45. # Add padding between the images
  46. padding = ((0, nx*ny - length), (0, padsize), (0, padsize)) + ((0, 0),) * (images.ndim - 3)
  47. padded = np.pad(images, padding, mode='constant', constant_values=255)
  48. # Tile the images beside each other
  49. tiles = padded.reshape( (ny, nx) + padded.shape[1:]).transpose( (0,2,1,3) + tuple(range(4, padded.ndim + 1)))
  50. tiles = tiles.reshape((ny * tiles.shape[1], nx * tiles.shape[3]) + tiles.shape[4:])
  51. return tiles
  52. def get_color_map(name):
  53. """
  54. Return a colormap as (redmap, greenmap, bluemap)
  55. Arguments:
  56. name -- the name of the colormap. If unrecognized, will default to 'jet'.
  57. """
  58. redmap = [0]
  59. greenmap = [0]
  60. bluemap = [0]
  61. if name == 'white':
  62. # essentially a noop
  63. redmap = [0,1]
  64. greenmap = [0,1]
  65. bluemap = [0,1]
  66. elif name == 'simple':
  67. redmap = [0,1,1,1]
  68. greenmap = [0,0,1,1]
  69. bluemap = [0,0,0,1]
  70. elif name == 'hot':
  71. redmap = [0, 0.03968253968253968, 0.07936507936507936, 0.119047619047619, 0.1587301587301587, 0.1984126984126984, 0.2380952380952381, 0.2777777777777778, 0.3174603174603174, 0.3571428571428571, 0.3968253968253968, 0.4365079365079365, 0.4761904761904762, 0.5158730158730158, 0.5555555555555556, 0.5952380952380952, 0.6349206349206349, 0.6746031746031745, 0.7142857142857142, 0.753968253968254, 0.7936507936507936, 0.8333333333333333, 0.873015873015873, 0.9126984126984127, 0.9523809523809523, 0.992063492063492, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
  72. greenmap = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603163, 0.0714285714285714, 0.1111111111111112, 0.1507936507936507, 0.1904761904761905, 0.23015873015873, 0.2698412698412698, 0.3095238095238093, 0.3492063492063491, 0.3888888888888888, 0.4285714285714284, 0.4682539682539679, 0.5079365079365079, 0.5476190476190477, 0.5873015873015872, 0.6269841269841268, 0.6666666666666665, 0.7063492063492065, 0.746031746031746, 0.7857142857142856, 0.8253968253968254, 0.8650793650793651, 0.9047619047619047, 0.9444444444444442, 0.984126984126984, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
  73. bluemap = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.04761904761904745, 0.1269841269841265, 0.2063492063492056, 0.2857142857142856, 0.3650793650793656, 0.4444444444444446, 0.5238095238095237, 0.6031746031746028, 0.6825396825396828, 0.7619047619047619, 0.8412698412698409, 0.92063492063492, 1]
  74. elif name == 'rainbow':
  75. redmap = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9365079365079367, 0.8571428571428572, 0.7777777777777777, 0.6984126984126986, 0.6190476190476191, 0.53968253968254, 0.4603174603174605, 0.3809523809523814, 0.3015873015873018, 0.2222222222222223, 0.1428571428571432, 0.06349206349206415, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603208, 0.08465608465608465, 0.1375661375661377, 0.1904761904761907, 0.2433862433862437, 0.2962962962962963, 0.3492063492063493, 0.4021164021164023, 0.4550264550264553, 0.5079365079365079, 0.5608465608465609, 0.6137566137566139, 0.666666666666667]
  76. greenmap = [0, 0.03968253968253968, 0.07936507936507936, 0.119047619047619, 0.1587301587301587, 0.1984126984126984, 0.2380952380952381, 0.2777777777777778, 0.3174603174603174, 0.3571428571428571, 0.3968253968253968, 0.4365079365079365, 0.4761904761904762, 0.5158730158730158, 0.5555555555555556, 0.5952380952380952, 0.6349206349206349, 0.6746031746031745, 0.7142857142857142, 0.753968253968254, 0.7936507936507936, 0.8333333333333333, 0.873015873015873, 0.9126984126984127, 0.9523809523809523, 0.992063492063492, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9841269841269842, 0.9047619047619047, 0.8253968253968256, 0.7460317460317465, 0.666666666666667, 0.587301587301587, 0.5079365079365079, 0.4285714285714288, 0.3492063492063493, 0.2698412698412698, 0.1904761904761907, 0.1111111111111116, 0.03174603174603208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  77. bluemap = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01587301587301582, 0.09523809523809534, 0.1746031746031744, 0.2539682539682535, 0.333333333333333, 0.412698412698413, 0.4920634920634921, 0.5714285714285712, 0.6507936507936507, 0.7301587301587302, 0.8095238095238093, 0.8888888888888884, 0.9682539682539679, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
  78. elif name == 'winter':
  79. greenmap = [0, 1]
  80. bluemap = [1, 0.5]
  81. else:
  82. if name != 'jet':
  83. print 'Warning: colormap "%s" not supported. Using jet instead.' % name
  84. redmap = [0,0,0,0,0.5,1,1,1,0.5]
  85. greenmap = [0,0,0.5,1,1,1,0.5,0,0]
  86. bluemap = [0.5,1,1,1,0.5,0,0,0,0]
  87. return 255.0 * np.array(redmap), 255.0 * np.array(greenmap), 255.0 * np.array(bluemap)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/782829
推荐阅读
相关标签
  

闽ICP备14008679号