keras-io icon indicating copy to clipboard operation
keras-io copied to clipboard

ctc_decode return value is all -1

Open moseshu opened this issue 3 years ago • 0 comments
trafficstars

I use ctc to train a ASR model, but the result value is ,the below is the result of keras.backend.ctc_decode(pred, input_length=input_len, greedy=True).

what happend to my program?the log probability if over than 1 I think the -1 is blank

`

my code is :

def decode_batch_predictions(pred): input_len = np.ones(pred.shape[0]) * pred.shape[1] print("input_len",input_len) decoded = keras.backend.ctc_decode(pred, input_length=input_len, greedy=True) print('decoded=',decoded) # Use greedy search. For complex tasks, you can use beam search results = keras.backend.ctc_decode(pred, input_length=input_len, greedy=True)[0][0] # print(results) # Iterate over the results and get back the text output_text = [] for result in results: result = tf.strings.reduce_join(num_to_char(result)).numpy().decode("utf-8") output_text.append(result) return output_text ` decoded= ([<tf.Tensor: shape=(16, 466), dtype=int64, numpy= array([[-1, -1, -1, ..., -1, -1, -1], [-1, -1, -1, ..., -1, -1, -1], [-1, -1, -1, ..., -1, -1, -1], ..., [-1, -1, -1, ..., -1, -1, -1], [-1, -1, -1, ..., -1, -1, -1], [-1, -1, -1, ..., -1, -1, -1]])>], <tf.Tensor: shape=(16, 1), dtype=float32, numpy= array([[35.042274], [37.707462], [38.153233], [35.105343], [36.71848 ], [34.76342 ], [35.91048 ], [34.199417], [34.877655], [35.28045 ], [33.835865], [36.413853], [35.588364], [36.602173], [35.19414 ], [36.197643]], dtype=float32)>)

moseshu avatar Mar 20 '22 15:03 moseshu