**tensorflow对应的操作有一些封装好的库。**很多操作可以直接调用,对张量进行操作。
本篇blog只是简单的列举了几个用的较多的必备函数。
tf.strings
常用于推荐算法,NLP场景。对字符串进行分割等等。
IN:tf.strings.bytes_split('hello')
OUT:<tf.Tensor: id=109, shape=(5,), dtype=string, numpy=array([b'h', b'e', b'l', b'l', b'o'], dtype=object)>
如果不知道函数的功能,可以调用help函数进行查看和学习help(),例:
IN:help(tf.strings.split)
OUT:Help on function string_split_v2 in module tensorflow.python.ops.ragged.ragged_string_ops:
string_split_v2(input, sep=None, maxsplit=-1, name=None)
Split elements of `input` based on `sep` into a `RaggedTensor`.
Let N be the size of `input` (typically N will be the batch size). Split each
element of `input` based on `sep` and return a `SparseTensor` or
`RaggedTensor` containing the split tokens. Empty tokens are ignored.
Example:
```python
>>> tf.strings.split('hello world')
<Tensor ['hello', 'world']>
>>> tf.strings.split(['hello world', 'a b c'])
<tf.RaggedTensor [['hello', 'world'], ['a', 'b',