概要
wslのtensorflowでkerasのbackendを試す。
環境
windows 10
wsl ubuntu 18.04
tensorflow 1.5.0
python 3.6.9
backendとは
Kerasはモデルレベルのライブラリで,深層学習モデルを開発するための高水準な構成要素を提供します。
テンソル積,畳み込みなどのような低水準の操作をKeras自身で扱うことはありません。
backendが担当します。テンソルを取り扱うライブラリです。
現在は,Kerasは3つのバックエンドが利用可能で,それはTensorFlowバックエンドとTheanoバックエンド,そしてCNTKバックエンドです。
tensorflowでのbackendの呼び出し法
from tensorflow.python.keras import backend as K
backend一覧
命令 | 内容 |
---|---|
K.abs | 要素ごとの絶対値 Element-wise absolute value. |
K.all | ビット単位の縮約(論理AND) Bitwise reduction (logical AND). |
K.any | ビット単位の縮約(論理OR) Bitwise reduction (logical OR). |
K.arange | 整数の並びからなる1階テンソルを作成します Creates a 1D tensor containing a sequence of integers. |
K.argmax | テンソルの軸に沿った最大値の添字を返します Returns the index of the maximum value along an axis. |
K.argmin | テンソルの軸に沿った最小値の添字を返します Returns the index of the minimum value along an axis. |
K.backend | Active Keras backend |
K.batch_dot | バッチ式のドット積 Batchwise dot product. |
K.batch_flatten | n階テンソルを0番目の次元が保たれるように2階テンソルに変換します Turn a nD tensor into a 2D tensor with same 1st dimension. |
K.batch_get_value | 1つ以上のテンソルの変数の値を返します Returns the value of more than one tensor variable. |
K.batch_normalization | 与えられたmean,var,beta,gammaを使ってxにbatch normalizationを適用します Applies batch normalization on x given mean, var, beta and gamma. |
K.batch_set_value | 複数のテンソルの変数の値を一度にセットします Sets the values of many tensor variables at once. |
K.bias_add | テンソルにバイアスベクトルを付加します Adds a bias vector to a tensor. |
K.binary_crossentropy | 出力テンソルと目標テンソルの間のバイナリクロスエントロピー Binary crossentropy between an output tensor and a target tensor. |
K.cast_to_floatx | Numpy配列をデフォルトのKerasのfloat型にキャストします Cast an array to the default Keras float type. |
K.cast | テンソルを異なる型にキャストします Casts a tensor to a different dtype and returns it. |
K.categorical_crossentropy | 出力テンソルと目標テンソルの間のカテゴリカルクロスエントロピー Categorical crossentropy between an output tensor and a target tensor. |
K.clear_session | 現在のTFグラフを壊し,新たなものを作成します Destroys the current TF graph and creates a new one. |
K.clip | 要素ごとのクリッピング Element-wise value clipping. |
K.concatenate | 指定した軸に沿ってテンソルのリストを連結します Concatenates a list of tensors alongside the specified axis. |
K.constant | 引数value, dtype=None, shape=None, name=None Creates a constant tensor. |
K.conv1d | 1次元の畳み込み 1D convolution. |
K.conv2d_transpose | 2次元の逆畳み込み(すなわち,転置畳み込み) 2D deconvolution (i.e. transposed convolution). |
K.conv2d | 2次元の畳み込み 2D convolution. |
K.conv3d_transpose | 3D deconvolution (i.e. transposed convolution). |
K.conv3d | 3次元の畳み込み 3D convolution. |
K.cos | 要素ごとにxのcosを計算します Computes cos of x element-wise. |
K.count_params | Kerasの変数におけるスカラーの数を返します Returns the static number of elements in a Keras variable or tensor. |
K.ctc_batch_cost | 各バッチ要素に対してCTCのlossアルゴリズムを実行 Runs CTC loss algorithm on each batch element. |
K.ctc_decode | softmaxの出力をデコードします Decodes the output of a softmax. |
K.ctc_label_dense_to_sparse | CTCのラベルを密からスパースなものに変換しますConverts CTC labels from dense to sparse. |
K.cumprod | テンソルに対して,指定した軸に沿って累積積を計算します Cumulative product of the values in a tensor, alongside the specified axis. |
K.cumsum | テンソルに対して,指定した軸に沿って累積和を計算します Cumulative sum of the values in a tensor, alongside the specified axis. |
K.depthwise_conv2d | 2D convolution with separable filters. |
K.dot | 2つのテンソル(かつ/または変数)を掛け合わせ,テンソルを返します Multiplies 2 tensors (and/or variables) and returns a tensor. |
K.dropout | xの要素をランダムに0にセットし,その上,テンソル全体をスケールさせます Sets entries in x to zero at random, while scaling the entire tensor. |
K.dtype | Kerasのテンソル,または変数のdtypeを文字列で返します Returns the dtype of a Keras tensor or variable, as a string. |
K.elu | 活性化関数 Exponential linear unit. |
K.epsilon | 数値演算で使われる微小量を返します Fuzz factor used in numeric expressions. |
K.equal | 2つのテンソル間の要素ごとの等値性 Element-wise equality between two tensors. |
K.eval | テンソルの変数値を評価します Evaluates the value of a variable. |
K.exp | 要素ごとの指数関数値 Element-wise exponential. |
K.expand_dims | 添字"axis"でのサイズ1の次元を加えます Adds a 1-sized dimension at index "axis". |
K.eye | 単位行列をインスタンス化し,それを返します Instantiate an identity matrix and returns it. |
K.flatten | 平滑化されたテンソル Flatten a tensor. |
K.floatx | デフォルトのfloat型を文字列で返します Default float type |
K.foldl | fnを使って左から右にelemsの要素を結合させることでelemsを縮約します Reduce elems using fn to combine them from left to right. |
K.foldr | fnを使って右から左にelemsの要素を結合させることでelemsを縮約します Reduce elems using fn to combine them from right to left. |
K.function | Kerasの関数のインスタンスを作成します Instantiates a Keras function |
K.gather | テンソルのreferenceにおける添字の要素indicesを探索します Retrieves the elements of indices indices in the tensor reference. |
K.get_session | TF session to be used by the backend. |
K.get_uid | デフォルトのグラフにおけるuidを取得します Get the uid for the default graph. |
K.get_value | 変数の値を返します Returns the value of a variable. |
K.get_variable_shape | Returns the shape of a variable. |
K.gradients | variablesのlossに関しての勾配を返します Returns the gradients of variables w.r.t. loss. |
K.greater_equal | 要素ごとの(x >= y)の真理値 Element-wise truth value of (x >= y). |
K.greater | 要素ごとの(x > y)の真理値 Element-wise truth value of (x > y). |
K.hard_sigmoid | セグメントごとのシグモイドの線形近似 Segment-wise linear approximation of sigmoid. |
K.identity | 入力されたテンソルと同じ内容を持つテンソルを返します Returns a tensor with the same content as the input tensor. |
K.image_data_format | 画像におけるデフォルトのフォーマット規則('channels_first' か 'channels_last')を返します Default image data format convention ('channels_first' or 'channels_last'). |
K.in_test_phase | テストフェーズではxを選択し,それ以外ではaltを選択します Selects x in test phase, and alt otherwise. |
K.in_top_k | Returns whether the targets are in the top k predictions. |
K.in_train_phase | 学習フェーズではxを選択し,それ以外ではaltを選択します Selects x in train phase, and alt otherwise. |
K.int_shape | 整数,またはNoneからなるタプルとしての変数,またはテンソルのshapeを返します Returns the shape of tensor or variable as a list of int or NULL entries. |
K.is_keras_tensor | Kerasのテンソルかどうかを返します Returns whether x is a Keras tensor. |
K.is_placeholder | プレースホルダか否かを返します Returns whether x is a placeholder. |
K.is_sparse | テンソルがスパースかどうかを返します Returns whether a tensor is a sparse tensor. |
K.l2_normalize | 指定した軸に沿って,L2ノルムでテンソルを正則化します Normalizes a tensor wrt the L2 norm alongside the specified axis. |
K.learning_phase | 学習フェーズのフラグを返します Returns the learning phase flag. |
K.less_equal | 要素ごとの(x <= y)の真理値 Element-wise truth value of (x <= y). |
K.less | 要素ごとの(x < y)の真理値 Element-wise truth value of (x < y). |
K.local_conv1d | 重みを共有しない1次元畳み込みの適用 Apply 1D conv with un-shared weights. |
K.local_conv2d | 重みを共有しない2次元畳み込みの適用 Apply 2D conv with un-shared weights. |
K.log | 要素ごとの対数 Element-wise log. |
K.logsumexp | log(sum(exp(テンソルの次元を横断した要素)))を計算します Computes log(sum(exp(elements across dimensions of a tensor))). |
K.manual_variable_initialization | 手動で変数を初期化するかのフラグがセットされます Sets the manual variable initialization flag. |
K.map_fn | 関数fnをelemsの要素全てに対して当てはめ,その出力を返します Map the function fn over the elements elems and return the outputs. |
K.max | テンソル内の最大値 Maximum value in a tensor. |
K.maximum | 2つのテンソルの要素ごとの最大値 Element-wise maximum of two tensors. |
K.mean | 指定した軸に沿ったテンソルの平均を計算します Mean of a tensor, alongside the specified axis. |
K.min | テンソル内の最小値 Minimum value in a tensor. |
K.minimum | 2つのテンソルの要素ごとの最小値 Element-wise minimum of two tensors. |
K.moving_average_update | 変数における移動平均を計算します Compute the moving average of a variable. |
K.ndim | テンソルの軸の数を整数で返します Returns the number of axes in a tensor, as an integer. |
K.normalize_batch_in_training | 平均と標準偏差を計算したのちに,バッチとしてbatch_normalizationを適用します Computes mean and std for batch then apply batch_normalization on batch. |
K.not_equal | 2つのテンソル間の要素ごとの不等性 Element-wise inequality between two tensors. |
K.one_hot | 整数のテンソルone-hot表現を導出します Computes the one-hot representation of an integer tensor. |
K.ones_like | 別のテンソルと同じshapeを持つ全要素が1の変数のインスタンスを作成します Instantiates an all-ones variable of the same shape as another tensor. |
K.ones | 全要素が1の変数をインスタンス化し,それを返します Instantiates an all-ones tensor variable and returns it. |
K.permute_dimensions | テンソルにおける軸の順序を変更します Permutes axes in a tensor. |
K.placeholder | プレースホルダーのテンソルをインスタンス化し,それを返します Instantiates a placeholder tensor and returns it. |
K.pool2d | 2次元のプーリング 2D Pooling. |
K.pool3d | 3次元のプーリング 3D Pooling. |
K.pow | 要素ごとの指数乗 Element-wise exponentiation. |
K.print_tensor | messageと評価されたテンソルの値を表示します Prints message and the tensor value when evaluated. |
K.prod | テンソルに対して,指定した軸に沿って積を計算します Multiplies the values in a tensor, alongside the specified axis. |
K.random_binomial | 二項分布の値を持つテンソルを返します Returns a tensor with random binomial distribution of values. |
K.random_normal_variable | ガウス分布からサンプリングされた値を持つ変数のインスタンスを作成します Instantiates a variable with values drawn from a normal distribution. |
K.random_normal | ガウス分布の値を持つテンソルを返します Returns a tensor with normal distribution of values. |
K.random_uniform_variable | 一様分布からサンプリングされた値を持つ変数のインスタンスを作成します Instantiates a variable with values drawn from a uniform distribution. |
K.random_uniform | 一様分布の値を持つテンソルを返します Returns a tensor with uniform distribution of values. |
K.relu | 活性化関数 Rectified linear unit. |
K.repeat_elements | xがshape(s1, s2, s3)を持ち,axisが1の場合,この出力はshape(s1, s2 * rep, s3)を持ちます Repeats the elements of a tensor along an axis. |
K.repeat | 2階テンソルを繰り返します Repeats a 2D tensor. |
K.reset_uids | グラフの識別子をリセットします Reset graph identifiers. |
K.reshape | 指定したshapeにテンソルを整形します Reshapes a tensor to the specified shape. |
K.resize_images | 4階テンソルに含まれる画像をリサイズします Resizes the images contained in a 4D tensor. |
K.resize_volumes | 5階テンソルに含まれるvolumeをリサイズします Resizes the volume contained in a 5D tensor. |
K.reverse | 指定した軸に沿ってテンソルを逆順にする Reverse a tensor along the specified axes. |
K.rnn | テンソルの時間次元にわたって反復します Iterates over the time dimension of a tensor |
K.round | 要素ごとの最も近い整数への丸め Element-wise rounding to the closest integer. |
K.separable_conv2d | separableフィルタ込みで2次元の畳み込み 2D convolution with separable filters. |
K.set_epsilon | 数値演算で使われる微小量をセットします Fuzz factor used in numeric expressions. |
K.set_floatx | デフォルトのfloat型をセットします Default float type |
K.set_learning_phase | 値を固定化するための学習フェーズをセットします Sets the learning phase to a fixed value. |
K.set_value | Numpy 配列から,変数の値を設定します Sets the value of a variable, from an R array. |
K.set_session | TF session to be used by the backend. |
K.set_image_data_format | デフォルトのフォーマット規則をセットします Default image data format convention ('channels_first' or 'channels_last'). |
K.shape | テンソル,または変数のshapeを返します Returns the symbolic shape of a tensor or variable. |
K.sigmoid | 活性化関数 Element-wise sigmoid. |
K.sign | 要素ごとの符号 Element-wise sign. |
K.sin | 要素ごとにxのsinを計算します Computes sin of x element-wise. |
K.softmax | Softmax of a tensor. |
K.softplus | Softplus of a tensor. |
K.softsign | Softsign of a tensor. |
K.sparse_categorical_crossentropy | 整数の目標におけるカテゴリカルクロスエントロピー Categorical crossentropy with integer targets. |
K.spatial_2d_padding | 4階テンソルの2番目と3番目の次元に対してパディングを行います Pads the 2nd and 3rd dimensions of a 4D tensor. |
K.spatial_3d_padding | 5階テンソルに対して深さ,高さ,幅を表す次元に沿って0パディングを行います Pads 5D tensor with zeros along the depth, height, width dimensions. |
K.sqrt | 要素ごとの平方根 Element-wise square root. |
K.square | 要素ごとの二乗 Element-wise square. |
K.squeeze | テンソルから添字"axis"での1次元を除きます Removes a 1-dimension from the tensor at index "axis". |
K.stack | ランクRのテンソルのリストをランクR+1のテンソルに積み上げます Stacks a list of rank R tensors into a rank R+1 tensor. |
K.std | 指定した軸に沿ったテンソルの標準偏差を計算します Standard deviation of a tensor, alongside the specified axis. |
K.stop_gradient | 全ての変数に関して,0の勾配を持つvariableを返します Returns variables but with zero gradient w.r.t. every other variable. |
K.sum | テンソルに対して,指定した軸に沿って和を計算します Sum of the values in a tensor, alongside the specified axis. |
K.switch | スカラー値に応じて2つの命令を入れ替えます Switches between two operations depending on a scalar value. |
K.tanh | 活性化関数 Element-wise tanh. |
K.temporal_padding | 3階テンソルの真ん中の次元に対してパディングを行います Pads the middle dimension of a 3D tensor. |
K.tile | xをnでタイル状に配置したテンソルを作成します Creates a tensor by tiling x by n. |
K.to_dense | スパースなテンソルを密なテンソルに変換し,それを返します Converts a sparse tensor into a dense tensor and returns it. |
K.transpose | 行列を転置します Transposes a tensor and returns it. |
K.truncated_normal | 切断ガウス分布の値を持つテンソルを返します Returns a tensor with truncated random normal distribution of values. |
K.update_add | xの値をincrementで加算することで更新する Update the value of x by adding increment. |
K.update_sub | xの値をdecrementで減算することで更新する Update the value of x by subtracting decrement. |
K.update | xの値をnew_xのものに更新する Update the value of x to new_x. |
K.var | 指定した軸に沿ったテンソルの分散を計算します Variance of a tensor, alongside the specified axis. |
K.variable | テンソルのインスタンス化し,それを返します Instantiates a variable and returns it. |
K.zeros_like | 別のテンソルと同じshapeを持つ全要素が0の変数のインスタンスを作成します Instantiates an all-zeros variable of the same shape as another tensor. |
K.zeros | 全要素が0の変数をインスタンス化し,それを返します Instantiates an all-zeros variable and returns it. |
以上。