-
3/25<Kaggle>/[TensorFlow Speech Recognition] 2022. 3. 25. 21:28728x90
- np.random.RandomState() if state is None else state
# 방법1 if state is None: np.random.RandomState() else: state # 방법2 np.random.RandomState() if state is None else state
- .real
a = 1+2j a.real # 1.0 a.imag # 2.0
- 이중 def
def abc(x): def ab(*arg, **kwargs) return x(*arg, **kwargs) return ab
- 이중 for문 + 람다함수
# 방법1 flatten = lambda l: [item for sublist in l for item in sublist] # 방법2 for sublist in l : for item in sublist : item
- assert == if
assert sample_rate==16000
- np.row_stack() == np.vstack()
- np.expand_dims(x, axis = 2)
a = np.array([1,2]) a.shape # (2,) a.expand_dims(a, axis=0) a.shape # (1,2)
- tf의 Variance Scope 경로메커니즘
= tf.get_variance(name, shape, initializer) + tf.variance_scope(scope_name)initializer =
tf.constant_initializer(value)
+ tf.random_uniform_initializer(a, b) # [a, b]를 균일하게 초기화 합니다,
+ tf.random_normal_initializer(mean, stddev) # 주어진 평균 및 표준 편차로 정규 분포에서 초기화합니다.ex)
def image_filter():
with tf.variance_scope('a'):
tf.variance_scope('b'):
tf.get_variance('weight') # 'a/b/weight'with tf.variable_scope("image_filters") as scope:
result1 = my_image_filter(image1)
scope.reuse_variables()
result2 = my_image_filter(image2)def my_image_filter(input_images): with tf.variable_scope("conv1"): # Variables created here will be named "conv1/weights", "conv1/biases". relu1 = conv_relu(input_images, [5, 5, 32, 32], [32]) with tf.variable_scope("conv2"): # Variables created here will be named "conv2/weights", "conv2/biases". return conv_relu(relu1, [5, 5, 32, 32], [32])
# 연속호출 불가 result1 = my_image_filter(image1) result2 = my_image_filter(image2) # Raises ValueError(... conv1/weights already exists ...)
# 연속호출가능 - .reuse_variables() with tf.variable_scope("image_filters") as scope: result1 = my_image_filter(image1) scope.reuse_variables() result2 = my_image_filter(image2)
# op 함수 name with tf.variable_scope("foo"): x = 1.0 + tf.get_variable("v", [1]) assert x.op.name == "foo/add"
읽은것 :
https://tensorflowkorea.gitbooks.io/tensorflow-kr/content/g3doc/how_tos/variables/
https://tensorflowkorea.gitbooks.io/tensorflow-kr/content/g3doc/how_tos/variable_scope/
728x90