ShapedArray

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

ShapedArray เป็นอาร์เรย์หลายมิติ มีรูปร่างซึ่งมีประเภท [Int] และกำหนดขนาดอาร์เรย์ และใช้ TensorBuffer ภายในเป็นที่เก็บข้อมูล

  • ขนาดของอาร์เรย์

    คำประกาศ

    public private(set) var shape: [Int] { get }
  • จำนวนมิติของอาร์เรย์

    คำประกาศ

    public var rank: Int { get }
  • จำนวนสเกลาร์ทั้งหมดในอาร์เรย์

    คำประกาศ

    public var scalarCount: Int { get }
  • สร้าง ShapedArray ที่มีรูปร่างและสเกลาร์เหมือนกับอินสแตนซ์ที่ระบุ

    คำประกาศ

    public init(_ other: ShapedArray)
  • สร้าง ShapedArray ที่มีรูปร่างที่ระบุและสเกลาร์ที่อยู่ติดกันในลำดับหลักแถว

    เงื่อนไขเบื้องต้น

    จำนวนสเกลาร์ต้องเท่ากับผลคูณของขนาดของรูปร่าง

    คำประกาศ

    public init(shape: [Int], scalars: [Scalar])
  • สร้าง ShapedArray ที่มีรูปร่างและลำดับของสเกลาร์ที่ระบุในลำดับแถวหลัก

    เงื่อนไขเบื้องต้น

    จำนวนสเกลาร์ต้องเท่ากับผลคูณของขนาดของรูปร่าง

    คำประกาศ

    public init<S>(shape: [Int], scalars: S) where Scalar == S.Element, S : Sequence
  • สร้าง ShapedArray จากค่าสเกลาร์

    คำประกาศ

    public init(_ scalar: Scalar)
  • สร้าง ShapedArray ด้วยรูปร่างที่ระบุและค่าสเกลาร์ค่าเดียวที่ซ้ำกัน

    คำประกาศ

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

    พารามิเตอร์

    shape

    รูปร่างของ ShapedArray

    repeatedValue

    ค่าสเกลาร์ที่จะทำซ้ำ

  • สร้าง ShapedArray ด้วยรูปร่างที่ระบุและค่าสเกลาร์ค่าเดียวที่ซ้ำกัน

    คำประกาศ

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

    พารามิเตอร์

    repeatedValue

    ค่าสเกลาร์ที่จะทำซ้ำ

    shape

    รูปร่างของ ShapedArray

  • คำประกาศ

    public typealias Index = Int
  • คำประกาศ

    public typealias Element = ShapedArraySlice<Scalar>
  • คำประกาศ

    public typealias SubSequence = ShapedArraySlice<Scalar>
  • คำประกาศ

    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

    ช่วงดัชนีที่ต่อเนื่องกัน

  • เรียกการปิดด้วยตัวชี้ไปยังที่เก็บข้อมูลที่อยู่ติดกันของอาร์เรย์

    คำประกาศ

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

    พารามิเตอร์

    body

    การปิดด้วยพารามิเตอร์ UnsafeBufferPointer ที่ชี้ไปยังที่เก็บข้อมูลที่อยู่ติดกันสำหรับอาร์เรย์ หากไม่มีที่เก็บข้อมูลดังกล่าว ก็จะถูกสร้างขึ้น หากเนื้อหามีค่าที่ส่งคืน ค่านั้นก็จะใช้เป็นค่าที่ส่งคืนสำหรับเมธอด withUnsafeBufferPointer(_:) ด้วย อาร์กิวเมนต์ของพอยน์เตอร์ใช้ได้เฉพาะในช่วงระยะเวลาของการดำเนินการของเมธอดเท่านั้น

  • เรียกการปิดที่กำหนดด้วยตัวชี้ไปยังที่เก็บข้อมูลที่อยู่ติดกันที่ไม่แน่นอนของอาเรย์

    คำประกาศ

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

    พารามิเตอร์

    body

    การปิดด้วยพารามิเตอร์ UnsafeMutableBufferPointer ที่ชี้ไปยังที่เก็บข้อมูลที่อยู่ติดกันสำหรับอาร์เรย์ หากไม่มีที่เก็บข้อมูลดังกล่าว ก็จะถูกสร้างขึ้น หากเนื้อหามีค่าที่ส่งคืน ค่านั้นก็จะใช้เป็นค่าที่ส่งคืนสำหรับเมธอด withUnsafeMutableBufferPointer(_:) ด้วย อาร์กิวเมนต์ของพอยน์เตอร์ใช้ได้เฉพาะในช่วงระยะเวลาของการดำเนินการของเมธอดเท่านั้น

  • การแสดงข้อความของ ShapedArray นี้

    บันทึก

    ใช้ fullDescription สำหรับคำอธิบายที่ไม่สวยงามซึ่งแสดงสเกลาร์ทั้งหมด

    คำประกาศ

    public var description: String { get }
  • คำประกาศ

    public var playgroundDescription: Any { get }
  • คำประกาศ

    public var customMirror: Mirror { get }
มีจำหน่ายที่ `Scalar`: `TensorFlowScalar`
มีจำหน่ายที่ 'สเกลาร์': 'เท่าเทียม'
  • คำประกาศ

    public static func == (lhs: ShapedArray, rhs: ShapedArray) -> Bool
มีจำหน่ายที่ "สเกลาร์": "Hashable"
มีจำหน่ายที่ `Scalar`: `Codable`
มีจำหน่ายที่ `Scalar`: `_TensorFlowDataTypeCompatible`