第23章付録:深層学習のための道具
23.8.2. Functions23.8.2 関数
d2l.torch.add_to_class(Class)- Register functions as methods in created class.
英語のヒント
関数を、作成したクラスのメソッドとして登録する。
d2l.torch.bleu(pred_seq, label_seq, k)- Compute the BLEU.
英語のヒント
BLEUを計算する。
d2l.torch.check_len(a, n)- Check the length of a list.
英語のヒント
リストの長さを確かめる。
d2l.torch.check_shape(a, shape)- Check the shape of a tensor.
英語のヒント
テンソルの形を確かめる。
d2l.torch.corr2d(X, K)- Compute 2D cross-correlation.
英語のヒント
2次元の相互相関を計算する。
d2l.torch.cpu()- Get the CPU device.
英語のヒント
CPUのデバイスを得る。
d2l.torch.gpu(i=0)- Get a GPU device.
英語のヒント
GPUのデバイスを得る。
d2l.torch.init_cnn(module)- Initialize weights for CNNs.
英語のヒント
CNNの重みを初期化する。
d2l.torch.init_seq2seq(module)- Initialize weights for sequence-to-sequence learning.
英語のヒント
系列から系列への学習のための重みを初期化する。
d2l.torch.masked_softmax(X, valid_lens)- Perform softmax operation by masking elements on the last axis.
英語のヒント
最後の軸の要素をマスクしてソフトマックス演算を行う。
d2l.torch.num_gpus()- Get the number of available GPUs.
英語のヒント
使えるGPUの数を得る。
d2l.torch.plot(X, Y=None, xlabel=None, ylabel=None, legend=[], xlim=None, ylim=None, xscale='linear', yscale='linear', fmts=('-', 'm--', 'g-.', 'r:'), figsize=(3.5, 2.5), axes=None)- Plot data points.
英語のヒント
データ点をプロットする。
d2l.torch.set_axes(axes, xlabel, ylabel, xlim, ylim, xscale, yscale, legend)- Set the axes for matplotlib.
英語のヒント
matplotlibの軸を設定する。
d2l.torch.set_figsize(figsize=(3.5, 2.5))- Set the figure size for matplotlib.
英語のヒント
matplotlibの図の大きさを設定する。
d2l.torch.show_heatmaps(matrices, xlabel, ylabel, titles=None, figsize=(2.5, 2.5), cmap='Reds')- Show heatmaps of matrices.
英語のヒント
行列のヒートマップを表示する。
d2l.torch.show_list_len_pair_hist(legend, xlabel, ylabel, xlist, ylist)- Plot the histogram for list length pairs.
英語のヒント
リストの長さの組のヒストグラムをプロットする。
d2l.torch.try_all_gpus()- Return all available GPUs, or [cpu(),] if no GPU exists.
英語のヒント
使えるすべてのGPUを返す。GPUがなければ[cpu(),]を返す。
d2l.torch.try_gpu(i=0)- Return gpu(i) if exists, otherwise return cpu().
英語のヒント
gpu(i)があればそれを返し、なければcpu()を返す。
d2l.torch.use_svg_display()- Use the svg format to display a plot in Jupyter.
英語のヒント
Jupyterでプロットを表示するのにsvg形式を使う。