tensorflow2.0学习记录-张量与操作 之 操作

**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', 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值