2016-10-24 9 views
2

乱数を計算するために正規分布を使用しようとしています。Tensorflow変数として与えられた範囲で乱数を生成する方法

tf.truncated_normal(shape, stddev=0.1,seed=1, mean=0) 

が、私が手の数字は次のように、小数点以下の桁数とポイントを浮遊している:0.14845988

それはintとして、そして[min, max]などの与えられた範囲内の数値を生成させるための方法はありますか?

+2

tf.truncated_normalのみ浮動小数点タイプはサポートされています。 tf.random_uniformは、minval、maxvalおよびfloat32、float64、int32、またはint64をサポートします。 –

+0

それは今のところうまく動作します:) – Kasparov92

+1

私はそれに答えるでしょう、私たちはそれを閉じることができます –

答えて

7

tf.random_uniform支持MINVAL、MAXVALとのfloat32、のfloat64、INT32、又は

tf.random_uniform(shape, minval=0, maxval=None, dtype=tf.float32, seed=None, name=None) 

引数INT64:

shape: A 1-D integer Tensor or Python array. The shape of the output tensor. 
minval: A 0-D Tensor or Python value of type dtype. The lower bound on the range of random values to generate. Defaults to 0. 
maxval: A 0-D Tensor or Python value of type dtype. The upper bound on the range of random values to generate. Defaults to 1 if dtype is floating point. 
dtype: The type of the output: float32, float64, int32, or int64. 
seed: A Python integer. Used to create a random seed for the distribution. See set_random_seed for behavior. 
name: A name for the operation (optional). 
関連する問題