【问题标题】:What does ":" do in Python [duplicate]“:”在Python中做了什么[重复]
【发布时间】:2020-03-19 05:56:40
【问题描述】:

我试图了解 cifar10.py keras lib 中的基本 Tensorflow 函数,函数 load_batch

for i in range(1, 6):
    fpath = os.path.join(path, 'data_batch_' + str(i))
    (x_train[(i - 1) * 10000:i * 10000, :, :, :],
      y_train[(i - 1) * 10000:i * 10000]) = load_batch(fpath)

下面一行中的":" 是什么意思?

x_train[(i - 1) * 10000:i * 10000, :, :, :]

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    x_train 等是实现其接口的 numpy 数组或类似结构。 在这里你可以阅读关于 numpy 中的切片https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html

    或者更通用的关于 python 中的切片https://docs.python.org/3.7/library/stdtypes.html#common-sequence-operations

    【讨论】:

      猜你喜欢
      • 2013-09-15
      • 2013-11-19
      • 1970-01-01
      • 2012-02-26
      • 2011-01-02
      • 1970-01-01
      • 1970-01-01
      • 2014-07-22
      • 2017-03-02
      相关资源
      最近更新 更多