I am trying to show the images(image shape is  [2001515] and i wanna just plot the first channel [11515] the type is .mat) into the Tensorboard as follow :

images, labels = next(iter(train_loader))
grid = torchvision.utils.make_grid(images[:,1,:,:])
writer.add_image('images', grid, 0)   # here is the error line 
writer.add_graph(model, images)
writer.close()



imgbelsi.png1920×1080 398 KB

but I got this error :

Traceback (most recent call last):
  File "/home/joseph/.vscode/extensions/ms-python.python-2019.5.18678/pythonFiles/ptvsd_launcher.py", line 43, in <module>
    main(ptvsdArgs)
  File "/home/joseph/.vscode/extensions/ms-python.python-2019.5.18678/pythonFiles/lib/python/ptvsd/__main__.py", line 434, in main
    run()
  File "/home/joseph/.vscode/extensions/ms-python.python-2019.5.18678/pythonFiles/lib/python/ptvsd/__main__.py", line 312, in run_file
    runpy.run_path(target, run_name='__main__')
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/runpy.py", line 252, in run_path
    return _run_module_code(code, init_globals, run_name, path_name)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/joseph/Documents/HYM PhD 2019/Codes/SSH PRGS/hsicnnpio_18519_1/main.py", line 179, in <module>
    writer.add_image('images', grid, 0)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/site-packages/tensorboardX/writer.py", line 412, in add_image
    self.file_writer.add_summary(image(tag, img_tensor), global_step, walltime)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/site-packages/tensorboardX/summary.py", line 205, in image
    image = make_image(tensor, rescale=rescale)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/site-packages/tensorboardX/summary.py", line 243, in make_image
    image = Image.fromarray(tensor)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/site-packages/PIL/Image.py", line 2431, in fromarray
    raise TypeError("Cannot handle this data type")
TypeError: Cannot handle this data type


Thanks in advance