모양의 배열슬라이스

@frozen
public struct ShapedArraySlice<Scalar> : _ShapedArrayProtocol
extension ShapedArraySlice: RandomAccessCollection, MutableCollection
extension ShapedArraySlice: CustomStringConvertible
extension ShapedArraySlice: CustomPlaygroundDisplayConvertible
extension ShapedArraySlice: CustomReflectable
extension ShapedArraySlice: ExpressibleByArrayLiteral where Scalar: TensorFlowScalar
extension ShapedArraySlice: Equatable where Scalar: Equatable
extension ShapedArraySlice: Hashable where Scalar: Hashable
extension ShapedArraySlice: Codable where Scalar: Codable

ShapedArray 또는 ShapedArraySlice 인스턴스의 연속 조각입니다.

ShapedArraySlice 사용하면 ShapedArray 인스턴스의 연속 슬라이스에서 빠르고 효율적인 작업을 수행할 수 있습니다. ShapedArraySlice 인스턴스에는 자체 저장소가 없습니다. 대신, 기본 ShapedArray 저장소에 대한 보기를 제공합니다. ShapedArraySlice 요소 배열과 하위 배열이라는 두 가지 종류의 슬라이스를 나타낼 수 있습니다.

요소 배열은 ShapedArray 의 하위 차원 요소입니다. 해당 순위는 기본 순위보다 1 낮습니다. 요소 배열 슬라이스는 단일 Int32 인덱스를 사용하여 ShapedArray 인스턴스를 인덱싱하여 얻습니다.

예를 들어:

    var matrix = ShapedArray(shape: [2, 2], scalars: [0, 1, 2, 3])
    // `matrix` represents [[0, 1], [2, 3]].

    let element = matrix[0]
    // `element` is a `ShapedArraySlice` with shape [2]. It is an element
    // array, specifically the first element in `matrix`: [0, 1].

    matrix[1] = ShapedArraySlice(shape: [2], scalars: [4, 8])
    // The second element in `matrix` has been mutated.
    // `matrix` now represents [[0, 1, 4, 8]].

하위 배열은 ShapedArray 에 있는 요소의 연속 범위입니다. 하위 배열의 순위는 기본 순위와 동일하지만 선행 차원은 슬라이스 범위의 개수입니다. 하위 배열 슬라이스는 요소 범위(선행 차원)를 나타내는 Range<Int32> 를 사용하여 ShapedArray 를 인덱싱하여 얻습니다. 내부적으로 범위를 사용하여 색인을 생성하는 prefix(:)suffix(:) 같은 메서드도 하위 배열을 생성합니다.

예를 들어:

    let zeros = ShapedArray(repeating: 0, shape: [3, 2])
    var matrix = ShapedArray(shape: [3, 2], scalars: Array(0..<6))
    // `zeros` represents [[0, 0], [0, 0], [0, 0]].
    // `matrix` represents [[0, 1], [2, 3], [4, 5]].

    let subarray = matrix.prefix(2)
    // `subarray` is a `ShapedArraySlice` with shape [2, 2]. It is a slice
    // of the first 2 elements in `matrix` and represents [[0, 1], [2, 3]].

    matrix[0..<2] = zeros.prefix(2)
    // The first 2 elements in `matrix` have been mutated.
    // `matrix` now represents [[0, 0], [0, 0], [4, 5]].
  • 배열의 차원 수입니다.

    선언

    public var rank: Int { get }
  • 배열의 모양입니다.

    선언

    public var shape: [Int] { get }
  • 배열의 총 스칼라 수입니다.

    선언

    public var scalarCount: Int { get }
  • 행 우선 순서로 지정된 모양과 연속 스칼라를 사용하여 ShapedArraySlice 를 만듭니다.

    전제조건

    스칼라의 수는 모양의 크기를 곱한 것과 같아야 합니다.

    선언

    public init(shape: [Int], scalars: [Scalar])
  • 행 우선 순서로 지정된 모양과 스칼라 시퀀스를 사용하여 ShapedArraySlice 를 만듭니다.

    전제조건

    스칼라의 수는 모양의 크기를 곱한 것과 같아야 합니다.

    선언

    public init<S>(shape: [Int], scalars: S) where Scalar == S.Element, S : Sequence
  • 스칼라 값에서 ShapedArraySlice 를 만듭니다.

    선언

    public init(_ scalar: Scalar)
  • 지정된 모양과 반복되는 단일 스칼라 값을 사용하여 ShapedArraySlice 를 만듭니다.

    선언

    @available(*, deprecated, renamed: "init(repeating:shape:﹚")
    public init(shape: [Int], repeating repeatedValue: Scalar)

    매개변수

    repeatedValue

    반복할 스칼라 값입니다.

    shape

    ShapedArraySlice 의 모양입니다.

  • 지정된 모양과 반복되는 단일 스칼라 값을 사용하여 ShapedArraySlice 를 만듭니다.

    선언

    public init(repeating repeatedValue: Scalar, shape: [Int])

    매개변수

    repeatedValue

    반복할 스칼라 값입니다.

    shape

    ShapedArraySlice 의 모양입니다.

  • ShapedArraySlice 로 표현되는 기본 ShapedArray 의 스칼라 범위입니다.

    선언

    var scalarRange: Range<Int> { get }
  • ShapedArraySlice 의 연속 저장소에 대한 포인터를 사용하여 클로저를 호출합니다.

    선언

    public func withUnsafeBufferPointer<Result>(
      _ body: (UnsafeBufferPointer<Scalar>) throws -> Result
    ) rethrows -> Result

    매개변수

    body

    ShapedArraySlice 에 대한 연속 저장소를 가리키는 UnsafeBufferPointer 매개변수가 있는 클로저입니다. 해당 저장소가 없으면 생성됩니다. body에 반환 값이 있으면 해당 값은 withUnsafeBufferPointer(_:) 메서드의 반환 값으로도 사용됩니다. 포인터 인수는 메서드가 실행되는 동안에만 유효합니다.

  • ShapedArraySlice 의 변경 가능한 연속 저장소에 대한 포인터를 사용하여 지정된 클로저를 호출합니다.

    선언

    public mutating func withUnsafeMutableBufferPointer<Result>(
      _ body: (inout UnsafeMutableBufferPointer<Scalar>) throws -> Result
    ) rethrows -> Result

    매개변수

    body

    ShapedArraySlice 에 대한 연속 저장소를 가리키는 UnsafeMutableBufferPointer 매개변수가 있는 클로저. 해당 저장소가 없으면 생성됩니다. body에 반환 값이 있으면 해당 값은 withUnsafeMutableBufferPointer(_:) 메서드의 반환 값으로도 사용됩니다. 포인터 인수는 메서드가 실행되는 동안에만 유효합니다.

  • 선언

    public typealias Index = Int
  • 선언

    public typealias Element = ShapedArraySlice
  • 선언

    public typealias SubSequence = ShapedArraySlice
  • 선언

    public var indices: Range<Int> { get }
  • 선언

    public var startIndex: Int { get }
  • 선언

    public var endIndex: Int { get }
  • 선행 차원의 인덱스로 지정된 요소 배열에 액세스합니다.

    선언

    public subscript(index: Int) -> Element { get set }

    매개변수

    index

    요소 배열의 인덱스입니다.

  • 연속된 인덱스 범위로 지정된 하위 배열에 액세스합니다.

    선언

    public subscript(bounds: Range<Int>) -> SubSequence { get set }

    매개변수

    bounds

    연속된 인덱스 범위.

  • ShapedArraySlice 의 텍스트 표현입니다.

    메모

    모든 스칼라를 표시하는 보기 좋게 인쇄되지 않은 표현에는 fullDescription 사용하십시오.

    선언

    public var description: String { get }
  • 선언

    public var playgroundDescription: Any { get }
  • 선언

    public var customMirror: Mirror { get }
'Scalar': 'TensorFlowScalar'에서 사용 가능
`Scalar`: `Equatable`에서 사용 가능
  • 선언

    public static func == (lhs: ShapedArraySlice, rhs: ShapedArraySlice) -> Bool
`Scalar`: `Hashable`에서 사용 가능
  • 선언

    public func hash(into hasher: inout Hasher)
`Scalar`: `Codable`에서 사용 가능