2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PytorchやNumpyで"e+"という指数表記を小数表記にする

Last updated at Posted at 2022-07-20

指数表記はわかりづらい

torch.tensorをprintすると、"+e"という指数表記になって、意味が分かりづらいことがあるじゃないですか。

[tensor([[1.14178e+01, 1.38472e+02, 1.03706e+02, 2.53196e+02, 9.22984e-01, 2.20000e+01],
        [3.59220e+02, 9.41330e+01, 5.77640e+02, 2.87894e+02, 9.12798e-01, 1.90000e+01]], device='cuda:0')]

それを、普通の小数表記に変えたい。

torch.set_printoptions

print_option.py
torch.set_printoptions(sci_mode=False)
print(some_tensor)

これで、小数表記になります。

[tensor([[   11.41777,   138.47192,   103.70560,   253.19629,     0.92298,    22.00000],
        [  359.22034,    94.13303,   577.64044,   287.89383,     0.91280,    19.00000]],device='cuda:0')]

ちなみに、npの指数標記を小数表記にするには、

np.set_printoptions(suppress=True)

🐣


フリーランスエンジニアです。
お仕事のご相談こちらまで
rockyshikoku@gmail.com

Core MLやARKitを使ったアプリを作っています。
機械学習/AR関連の情報を発信しています。

Twitter
Medium
GitHub

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?