0
인 오류 "파이썬`bool`로`tf.Tensor`"를 제공
나는 다음 코드 tensorflow here에서 구현 계층 정상화 LSTM 장치를 사용하고 싶습니다 :dynamic_rnn은 (LayerNormBasicLSTMCell에서) layer_norm는 텐서
TypeError: Using a `tf.Tensor` as a Python `bool` is not allowed. Use `if t is not None:` instead of `if t:` to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.
그리고 추적이 dynamic_rnn
로 돌아갑니다 : 다음 layer_norm
이 Tensor
때
import tensorflow as tf
import numpy as np
n = 10
batch_size_series = 16
x = tf.placeholder(shape=[None, None, 1], dtype=tf.float32, name="x")
layer_norm = tf.placeholder(tf.bool, name="normalize_layer")
cell = tf.contrib.rnn.LayerNormBasicLSTMCell(n, layer_norm=layer_norm)
initial_state = cell.zero_state(batch_size_series, dtype=tf.float32)
output_state, current_state = tf.nn.dynamic_rnn(cell, inputs=x, initial_state=initial_state, dtype=tf.float32)
나는 다음과 같은 오류가
Traceback (most recent call last):
File "test.py", line 19, in <module>
output_state, current_state = tf.nn.dynamic_rnn(multi_rnn_cell, inputs=x, initial_state=initial_state, dtype=tf.float32)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 614, in dynamic_rnn
dtype=dtype)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 777, in _dynamic_rnn_loop
swap_memory=swap_memory)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2816, in while_loop
result = loop_context.BuildLoop(cond, body, loop_vars, shape_invariants)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2640, in BuildLoop
pred, body, original_loop_vars, loop_vars, shape_invariants)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2590, in _BuildLoop
body_result = body(*packed_vars_for_body)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 762, in _time_step
(output, new_state) = call_cell()
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 748, in <lambda>
call_cell = lambda: cell(input_t, state)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 183, in __call__
return super(RNNCell, self).__call__(inputs, state)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 575, in __call__
outputs = self.call(inputs, *args, **kwargs)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 1066, in call
cur_inp, new_state = cell(cur_inp, cur_state)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 183, in __call__
return super(RNNCell, self).__call__(inputs, state)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 575, in __call__
outputs = self.call(inputs, *args, **kwargs)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/contrib/rnn/python/ops/rnn_cell.py", line 1340, in call
concat = self._linear(args)
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/contrib/rnn/python/ops/rnn_cell.py", line 1331, in _linear
if not self._layer_norm:
File "/Users/fghavamian/ve_tf2/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 528, in __bool__
여기에 뭔가가 있습니까?