美文网首页
2019-01-19 'helpers';ra

2019-01-19 'helpers';ra

作者: 七月那个阿瓜呀 | 来源:发表于2019-01-19 19:16 被阅读1次

1. 问题解决ModuleNotFoundError: No module named 'helpers'

pip install https://github.com/dianakhuang/pytumblr/archive/diana/python-3-support.zip

2. random_sequences 函数

功能 生成一批随机序列,序列长度 [length_from, length_to],数值大小 [vocab_lower, vocab_upper]

def random_sequences(length_from, length_to,
                     vocab_lower, vocab_upper,
                     batch_size):
    """ Generates batches of random integer sequences,
        sequence length in [length_from, length_to],
        vocabulary in [vocab_lower, vocab_upper]
    """
    if length_from > length_to:
            raise ValueError('length_from > length_to')

    def random_length():
        if length_from == length_to:
            return length_from
        return np.random.randint(length_from, length_to + 1)

    while True:
        yield [
            np.random.randint(low=vocab_lower,
                              high=vocab_upper,
                              size=random_length()).tolist()
            for _ in range(batch_size)
        ]
  1. axis
    numpy当中axis的值表示的是这个多维数组维度的下标,比如有一个二维数组a,a的shape是(5,6),也就是说a有5行6列,axis=0表示的就是[5,6]中的第一个维度,也就是axis=1表示的是[5,6]中的第二个维度,也就是
import numpy as np
a = np.array([[6,2,7],[4,6,5]])
# b表示沿着axis=0(行)这条轴取max,得到的结果就是把输入数组的'行'给消除了,2行变1行
b = a.max(axis=0)
print (b)
print (b.shape)

输出:
[6 6 7]
(3,)

# c表示沿着axis=1(列)这条轴取max,得到的结果就是把输入数组的'列'给消除了,3列变1列
c = a.max(axis=1)
print (c)
print (c.shape)

输出:
[7 6]
(2,)

相关文章

  • 2019-01-19 'helpers';ra

    1. 问题解决ModuleNotFoundError: No module named 'helpers' pip...

  • 学习笔记|语义分割常用损失函数

    参考:https://mp.weixin.qq.com/s/ra2qpFSbSuuJPDj39A5MWA 源于Gi...

  • 也怕PTE有文化- 杂谈髂(qia)腰肌(Akimbo)

    PTE - 每日RA跟读打卡 Day 39 Akimbo 这几天的更新由Brisk老师来完成,暂代小周周Stell...

  • 2019-01-19

    2019-01-19

  • 2020-04-03 Day8

    早上8:39-9:37 复习WFD 51-100 RA 10:00-11:00 9个 RS 11:00-11:53...

  • RA

    RA是一种无监督排序方法,适用于底层排序,主要优势有三点:1. 成本低2. 随机抽取样本,更符合数据真实分布。3....

  • 2019-01-19

    2019-01-19 周六 晴 你的身上总...

  • 片段二

    Ra :Guess what ? Ro:you got a job ? Ra :Are you kidding?I...

  • 又见雪花起

    又见雪花起 字数 881 · 阅读 0 2019-01-19 22:30 寒冬被...

  • RA:冥想

    「一的法則」中關於冥想的描述:發問者:冥想是否有”最佳的方式”?RA:我是 Ra,沒有。RA:事實上,沒有對或錯。...

网友评论

      本文标题:2019-01-19 'helpers';ra

      本文链接:https://www.haomeiwen.com/subject/mnbzdqtx.html