2016-10-24 2 views
2

난수를 계산하기 위해 정규 분포를 사용하려고합니다.주어진 범위의 난수를 Tensorflow 변수로 생성하는 방법

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

하지만 이런 내가 소수점 이하 자릿수로 포인트를 떠 얻을 번호 : 0.14845988

그것 (int)로 번호를 생성하게하고, [min, max] 같은 주어진 범위에서 할 수있는 방법이 있나요? MAXVAL

+2

이 지원됩니다. tf.random_uniform은 minval, maxval 및 float32, float64, int32 또는 int64를 지원합니다. –

+0

지금은 감사합니다. 감사합니다. – Kasparov92

+1

답변을 드리겠습니다. 닫을 수 있습니다. –

답변

7

tf.random_uniform 지원 MINVAL 및 float32, float64, INT32 또는 INT64

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

인수 : tf.truncated_normal에만 부동 소수점 유형에 대한

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). 
관련 문제