Object.assign python tương đương

Trả về một đối tượng mới với tất cả các cột ban đầu cùng với các cột mới. Các cột hiện tại được gán lại sẽ bị ghi đè

Show
Tham số**kwargs lệnh của {str. có thể gọi hoặc Sê-ri}

Tên cột là từ khóa. Nếu các giá trị có thể gọi được, chúng sẽ được tính toán trên DataFrame và được gán cho các cột mới. Có thể gọi không được thay đổi DataFrame đầu vào (mặc dù gấu trúc không kiểm tra nó). Nếu các giá trị không thể gọi được, (e. g. một Sê-ri, vô hướng hoặc mảng), chúng được gán đơn giản

ReturnsDữ LiệuKhung

Khung dữ liệu mới với các cột mới ngoài tất cả các cột hiện có

ghi chú

Có thể gán nhiều cột trong cùng một

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
55. Các mục sau này trong '**kwargs' có thể đề cập đến các cột mới được tạo hoặc sửa đổi trong 'df';

ví dụ

>>> df = pd.DataFrame({'temp_c': [17.0, 25.0]},
..                   index=['Portland', 'Berkeley'])
>>> df
          temp_c
Portland    17.0
Berkeley    25.0

Trường hợp giá trị có thể gọi được, được đánh giá trên df

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0

Ngoài ra, hành vi tương tự có thể đạt được bằng cách tham chiếu trực tiếp một Sê-ri hoặc trình tự hiện có

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0

Bạn có thể tạo nhiều cột trong cùng một lần gán trong đó một trong các cột phụ thuộc vào một cột khác được xác định trong cùng một lần gán

Xem các phiên từ Hội nghị chuyên đề WiML về các mô hình khuếch tán với KerasCV, ML trên thiết bị, v.v. Xem theo yêu cầu

  • TenorFlow
  • API
  • TenorFlow v2. 11. 0
  • con trăn

tf. Biến Sắp xếp ngăn nắp với các bộ sưu tập Lưu và phân loại nội dung dựa trên sở thích của bạn

Object.assign python tương đương
Xem nguồn trên GitHub

Xem hướng dẫn biến

tf.Variable(
    initial_value=None,
    trainable=None,
    validate_shape=True,
    caching_device=None,
    name=None,
    variable_def=None,
    dtype=None,
    import_scope=None,
    constraint=None,
    synchronization=tf.VariableSynchronization.AUTO,
    aggregation=tf.compat.v1.VariableAggregation.NONE,
    shape=None,
    experimental_enable_variable_lifting=True
)

Được sử dụng trong sổ ghi chép

Được sử dụng trong hướng dẫnĐược sử dụng trong hướng dẫn
  • Di chuyển các điểm kiểm tra mô hình
  • Giới thiệu về chuyển màu và phân biệt tự động
  • Giới thiệu về biến
  • Phân biệt tự động nâng cao
  • Hiệu suất tốt hơn với tf. hàm số
  • Nén mô hình có thể mở rộng
  • Vòng đào tạo tùy chỉnh với Keras và MultiWorkerMirroredStrategy
  • Chuyển giao phong cách thần kinh
  • Nén dữ liệu đã học
  • Ma trận lớp nhúng khởi động ấm

Một biến duy trì trạng thái chia sẻ, liên tục được thao tác bởi một chương trình

Hàm tạo

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
13 yêu cầu một giá trị ban đầu cho biến, giá trị này có thể là một
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 thuộc bất kỳ loại và hình dạng nào. Giá trị ban đầu này xác định loại và hình dạng của biến. Sau khi xây dựng, loại và hình dạng của biến được cố định. Giá trị có thể được thay đổi bằng một trong các phương thức gán

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>

Đối số

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
15 cho hàm tạo của
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
16 cho phép bạn tạo một biến có hình dạng ít được xác định hơn so với
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
17 của nó

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
0

Giống như bất kỳ

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 nào, các biến được tạo bằng
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
13 có thể được sử dụng làm đầu vào cho các hoạt động. Ngoài ra, tất cả các toán tử bị quá tải cho lớp
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 đều được chuyển sang các biến

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
4

Khi xây dựng một mô hình học máy, thường thuận tiện để phân biệt giữa các biến chứa các tham số mô hình có thể đào tạo và các biến khác, chẳng hạn như biến

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
21 được sử dụng để đếm các bước đào tạo. Để làm điều này dễ dàng hơn, hàm tạo biến hỗ trợ tham số
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
22.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
23 theo dõi các biến có thể huấn luyện theo mặc định

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
8

Các biến được tự động theo dõi khi được gán cho các thuộc tính của các loại kế thừa từ

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
24

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
0

Sau đó, theo dõi này cho phép lưu các giá trị biến vào các điểm kiểm tra đào tạo hoặc vào Các mô hình đã lưu bao gồm các biểu đồ TensorFlow được tuần tự hóa

Các biến thường được chụp và thao tác bởi

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
25s. Điều này hoạt động giống như cách chức năng không được trang trí sẽ có

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
2

Các biến được tạo bên trong một

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
25 phải được sở hữu bên ngoài hàm và chỉ được tạo một lần

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
4

Xem tài liệu

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
25 để biết chi tiết

lập luận

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
17A
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 hoặc đối tượng Python có thể chuyển đổi thành
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14, là giá trị ban đầu cho Biến. Giá trị ban đầu phải có hình dạng được chỉ định trừ khi
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
31 được đặt thành Sai. Cũng có thể gọi được mà không có đối số trả về giá trị ban đầu khi được gọi. Trong trường hợp đó,
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
32 phải được chỉ định. (Lưu ý rằng hàm khởi tạo từ init_ops. trước tiên py phải được liên kết với một hình dạng trước khi được sử dụng ở đây. )______433Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, GradientTapes sẽ tự động xem việc sử dụng biến này. Mặc định là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, trừ khi
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
36 được đặt thành
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
37, trong trường hợp đó, nó được đặt mặc định là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
38.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
31Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
38, cho phép khởi tạo biến với giá trị không xác định. Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, mặc định, hình dạng của
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
17 phải được biết.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
43Ghi chú. Đối số này chỉ hợp lệ khi sử dụng kiểu v1
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
44. Chuỗi thiết bị tùy chọn mô tả nơi Biến sẽ được lưu vào bộ đệm để đọc. Mặc định cho thiết bị của Biến. Nếu không phải là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
45, hãy lưu trữ trên thiết bị khác. Cách sử dụng điển hình là lưu vào bộ đệm trên thiết bị nơi các Hoạt động sử dụng Biến cư trú, để loại bỏ việc sao chép trùng lặp thông qua
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
46 và các câu lệnh có điều kiện khác.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47Tên tùy chọn cho biến. Mặc định là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
48 và được tự động thống nhất. Bộ đệm giao thức
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
49
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
50. Nếu không phải là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
45, hãy tạo lại đối tượng Biến với nội dung của nó, tham chiếu đến các nút của biến trong biểu đồ, đối tượng này phải tồn tại. Biểu đồ không thay đổi.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
49 và các đối số khác là loại trừ lẫn nhau.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
32Nếu được đặt, giá_trị_ban_đầu sẽ được chuyển đổi thành loại đã cho. Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
45, kiểu dữ liệu sẽ được giữ nguyên (nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
17 là Tensor) hoặc
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
56 sẽ quyết định.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
57Tùy chọn
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
58. Phạm vi tên để thêm vào
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
59 Chỉ được sử dụng khi khởi tạo từ bộ đệm giao thức.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
60Một hàm chiếu tùy chọn sẽ được áp dụng cho biến sau khi được cập nhật bởi một
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
61 (e. g. được sử dụng để thực hiện các ràng buộc định mức hoặc ràng buộc giá trị cho các trọng số của lớp). Hàm phải lấy đầu vào là Tensor chưa được phóng đại diện cho giá trị của biến và trả về Tensor cho giá trị được chiếu (phải có cùng hình dạng). Các ràng buộc không an toàn khi sử dụng khi thực hiện đào tạo phân tán không đồng bộ.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
36Cho biết khi nào một biến được phân phối sẽ được tổng hợp. Các giá trị được chấp nhận là các hằng số được định nghĩa trong lớp
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
63. Theo mặc định, đồng bộ hóa được đặt thành
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
64 và
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
65 hiện tại chọn thời điểm đồng bộ hóa.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
66Cho biết cách một biến phân tán sẽ được tổng hợp. Các giá trị được chấp nhận là các hằng số được định nghĩa trong lớp
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
67.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
15(tùy chọn) Hình dạng của biến này. Nếu Không, hình dạng của
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
17 sẽ được sử dụng. Khi đặt đối số này thành
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
70 (đại diện cho một hình dạng không xác định), biến có thể được gán với các giá trị của các hình dạng khác nhau.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
71Liệu có nên loại bỏ biến nếu nó ở trong một
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
25. Mặc định là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34. Khi đối số này là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, việc tạo biến sẽ tuân theo hành vi và hạn chế được mô tả tại đây. Nếu đối số này là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
38, thì mô tả đó không áp dụng và bạn có thể tự do tạo và sử dụng biến trong
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
25, như thể đó là "_______477 có thể thay đổi". Bạn không thể trả lại biến mặc dù

tăng

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
78Nếu cả
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
49 và giá trị_ban_đầu đều được chỉ định.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
78Nếu giá trị ban đầu không được chỉ định hoặc không có hình dạng và
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
31 là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34

Lưu ý rằng điều này khác với

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
83 chạy op khởi tạo biến trước khi trả về giá trị của nó. Phương thức này trả về tensor được op sử dụng để khởi tạo biến

Thuộc tính

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
66
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
60Trả về hàm ràng buộc được liên kết với biến này.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
86Thiết bị của biến này.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
32The
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
88 của biến này.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
89The
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
90 của biến này.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
17Trả về Tensor được sử dụng làm giá trị ban đầu cho biến.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
92Hoạt động khởi tạo cho biến này.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47Tên của biến này.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
94The
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
95 của biến này.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
15The
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
97 của biến này. _______436____433

Lớp học trẻ em

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
000

phương pháp

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 001

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
00

Gán một giá trị mới cho biến

Đây thực chất là một lối tắt cho

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
002

Đối số ______1003A
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14. Giá trị mới cho biến này.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, hãy sử dụng khóa trong khi chuyển nhượng.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47Tên của thao tác sẽ được tạo_______1008if True, sẽ trả về một giá trị nào đó đánh giá giá trị mới của biến; . ReturnsBiến được cập nhật. Nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
008 là sai, thay vào đó trả về Không có trong chế độ Háo hức và chỉ định op trong chế độ biểu đồ

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 010

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
10

Thêm một giá trị cho biến này

Đây thực chất là một lối tắt cho

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
011

Đối số ______1012A
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14. Giá trị để thêm vào biến này.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, sử dụng khóa trong quá trình vận hành.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47Tên của thao tác sẽ được tạo_______1008if True, sẽ trả về một giá trị nào đó đánh giá giá trị mới của biến; . ReturnsBiến được cập nhật. Nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
008 là sai, thay vào đó trả về Không có trong chế độ Háo hức và chỉ định op trong chế độ biểu đồ

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 019

Xem nguồn

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
0

Trừ một giá trị từ biến này

Đây thực chất là một lối tắt cho

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
020

Đối số ______1012A
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14. Giá trị để trừ từ biến này.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, sử dụng khóa trong quá trình vận hành.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47Tên của thao tác sẽ được tạo_______1008if True, sẽ trả về một giá trị nào đó đánh giá giá trị mới của biến; . ReturnsBiến được cập nhật. Nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
008 là sai, thay vào đó trả về Không có trong chế độ Háo hức và chỉ định op trong chế độ biểu đồ

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 028

Xem nguồn

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
1

Gán

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 cho biến này theo đợt

Tương tự với

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
030. Điều này giả định rằng biến này và các Spare_delta IndexedSlices có một loạt các kích thước hàng đầu giống nhau cho tất cả chúng và các bản cập nhật được thực hiện trên kích thước cuối cùng của các chỉ số. Nói cách khác, kích thước phải như sau

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
031
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
032
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
033

ở đâu

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
034
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
035
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
036

Và thao tác được thực hiện có thể được biểu thị dưới dạng

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
037

Khi thưa_delta. indices là một tensor 1D, thao tác này tương đương với

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
038

Để tránh thao tác này, người ta có thể lặp qua

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
039 đầu tiên của biến và sử dụng
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
038 trên các biến phụ dẫn đến việc cắt kích thước đầu tiên. Đây là một tùy chọn hợp lệ cho
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
041, nhưng kém hiệu quả hơn cách triển khai này

Args____1042
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 được gán cho biến này.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, sử dụng khóa trong quá trình vận hành.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật. Tăng______1047nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
042 không phải là
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
049

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 050

Xem nguồn

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
2

Tăng biến này cho đến khi đạt đến

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
051. (không dùng nữa)

Không dùng nữa. CHỨC NĂNG NÀY KHÔNG ĐƯỢC DÙNG. Nó sẽ được gỡ bỏ trong một phiên bản tương lai. Hướng dẫn cập nhật. Thích tập dữ liệu. phạm vi thay thế.

Khi Op đó được chạy, nó sẽ cố gắng tăng biến thêm 1052. Nếu việc tăng biến sẽ đưa nó lên trên

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
051 thì Op sẽ tăng ngoại lệ
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
054

Nếu không có lỗi nào xuất hiện, Op sẽ xuất giá trị của biến trước khi tăng

Đây thực chất là một phím tắt cho

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
055

Args____1051giá trị tại đó việc tăng biến sẽ gây ra lỗi. ReturnsA
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 sẽ giữ giá trị biến trước khi tăng. Nếu không có Op nào khác sửa đổi biến này, tất cả các giá trị được tạo ra sẽ khác biệt

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 058

Xem nguồn

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
3

Trong một phiên, tính toán và trả về giá trị của biến này

Đây không phải là một phương pháp xây dựng đồ thị, nó không thêm ops vào đồ thị

Phương thức tiện lợi này yêu cầu một phiên trong đó biểu đồ chứa biến này đã được khởi chạy. Nếu không có phiên nào được thông qua, phiên mặc định sẽ được sử dụng. Xem

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
059 để biết thêm thông tin về cách khởi chạy biểu đồ và về các phiên

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
4Args
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
060Phiên sử dụng để đánh giá biến này. Nếu không, phiên mặc định được sử dụng. ReturnsA numpy
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
061 với một bản sao giá trị của biến này

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 062

Xem nguồn

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
5

CHỨC NĂNG KHÔNG DÙNG

Không dùng nữa. CHỨC NĂNG NÀY KHÔNG ĐƯỢC DÙNG. Nó sẽ được gỡ bỏ trong một phiên bản tương lai. Hướng dẫn cập nhật. Sử dụng ref() thay thế.

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 063

Xem nguồn

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
6

Trả về một đối tượng

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
16 được tạo từ
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
49

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 066

Xem nguồn

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
7

Tập hợp các lát cắt từ

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
067 thành một Tenor có hình dạng được chỉ định bởi
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068

xem tf. thu thập_nd để biết chi tiết

Đối số ______1068A
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14. Phải là một trong các loại sau.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
071,
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
072. tenxơ chỉ số.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47Tên cho hoạt động (tùy chọn). ReturnsA
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14. Có cùng loại với
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
067

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 076

Xem nguồn

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
8

Bí danh của

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
077

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 078

Xem nguồn

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
9

Trả về giá trị của biến được khởi tạo. (không dùng nữa)

Không dùng nữa. CHỨC NĂNG NÀY KHÔNG ĐƯỢC DÙNG. Nó sẽ được gỡ bỏ trong một phiên bản tương lai. Hướng dẫn cập nhật. Sử dụng biến. read_value. Các biến trong 2. X được khởi tạo tự động cả trong háo hức và đồ thị (bên trong tf. defun) bối cảnh.

Bạn nên sử dụng cái này thay vì chính biến đó để khởi tạo một biến khác có giá trị phụ thuộc vào giá trị của biến này

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
00ReturnsA
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 giữ giá trị của biến này sau khi trình khởi tạo của nó chạy

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 080

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
01

Tải giá trị mới vào biến này. (không dùng nữa)

Không dùng nữa. CHỨC NĂNG NÀY KHÔNG ĐƯỢC DÙNG. Nó sẽ được gỡ bỏ trong một phiên bản tương lai. Hướng dẫn cập nhật. thích biến. gán có hành vi tương đương trong 2. X.

Ghi giá trị mới vào bộ nhớ của biến. Không thêm hoạt động vào biểu đồ

Phương thức tiện lợi này yêu cầu một phiên trong đó biểu đồ chứa biến này đã được khởi chạy. Nếu không có phiên nào được thông qua, phiên mặc định sẽ được sử dụng. Xem

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
059 để biết thêm thông tin về cách khởi chạy biểu đồ và về các phiên

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
02Args____1003Giá trị biến mới
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
060Phiên sử dụng để đánh giá biến này. Nếu không, phiên mặc định được sử dụng. Raises
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
78Phiên không được thông qua và không có phiên mặc định

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 008

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
03

Trả về giá trị của biến này, đọc trong ngữ cảnh hiện tại

Có thể khác với giá trị () nếu trên thiết bị khác, có phụ thuộc điều khiển, v.v.

ReturnsA
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 chứa giá trị của biến

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 087

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
04

Trả về một đối tượng tham chiếu có thể băm cho Biến này

Trường hợp sử dụng chính cho API này là đặt các biến trong một bộ/từ điển. Chúng tôi không thể đặt các biến trong một bộ/từ điển vì

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
088 không còn khả dụng kể từ Tensorflow 2. 0

Sau đây sẽ đưa ra một ngoại lệ bắt đầu từ 2. 0

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
05

Thay vào đó, chúng ta có thể sử dụng

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
089

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
06

Ngoài ra, đối tượng tham chiếu cung cấp hàm

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
090 trả về Biến ban đầu

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
07

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 091

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
08

Thêm

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 vào biến này

Args____1042
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 được thêm vào biến này.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, sử dụng khóa trong quá trình vận hành.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật. Tăng______1047nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
042 không phải là
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
049

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 401

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
09

Chia biến này cho

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029

Args____1042
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 để chia biến này cho.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, sử dụng khóa trong quá trình vận hành.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật. Tăng______1047nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
042 không phải là
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
049

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 411

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
40

Cập nhật biến này với giá trị tối đa là

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 và chính nó

Args____1042
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 để sử dụng làm đối số của max với biến này.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, sử dụng khóa trong quá trình vận hành.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật. Tăng______1047nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
042 không phải là
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
049

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 421

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
41

Cập nhật biến này với giá trị nhỏ nhất của

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 và chính nó

Args____1042
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 để sử dụng làm đối số của min với biến này.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, sử dụng khóa trong quá trình vận hành.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật. Tăng______1047nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
042 không phải là
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
049

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 431

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
42

Nhân biến này với

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029

Args____1042
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 để nhân biến này với.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, sử dụng khóa trong quá trình vận hành.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật. Tăng______1047nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
042 không phải là
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
049

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 441

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
43

Áp dụng phép cộng thưa thớt cho các giá trị hoặc lát riêng lẻ trong Biến

Biến có thứ hạng

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
442 và
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068 là một
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 của thứ hạng
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
445

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068 phải là tensor nguyên, chứa các chỉ số vào self. Nó phải có hình dạng
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
447 trong đó
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
448

Chiều trong cùng của

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068 (có chiều dài
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
450) tương ứng với các chỉ số thành phần tử (nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
451) hoặc lát (nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
452) dọc theo chiều thứ
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
450 của chính nó

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
454 là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 của hạng
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
456 với hình dạng

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
44

Ví dụ: giả sử chúng tôi muốn thêm 4 phần tử phân tán vào tenxơ hạng 1 thành 8 phần tử. Trong Python, bản cập nhật đó sẽ như thế này

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
45

Bản cập nhật kết quả cho v sẽ như thế này

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
46

Xem

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
457 để biết thêm chi tiết về cách cập nhật lát cắt

Args
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068Các chỉ số được sử dụng trong hoạt động.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
454Các giá trị được sử dụng trong hoạt động.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 461

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
47

Áp dụng phép trừ thưa thớt cho các giá trị hoặc lát cắt riêng lẻ trong Biến

Giả sử biến có thứ hạng

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
442 và
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068 là một
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 của thứ hạng
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
445

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068 phải là tensor nguyên, chứa các chỉ số vào self. Nó phải có hình dạng
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
447 trong đó
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
448

Chiều trong cùng của

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068 (có chiều dài
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
450) tương ứng với các chỉ số thành phần tử (nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
451) hoặc lát (nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
452) dọc theo chiều thứ
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
450 của chính nó

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
454 là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 của hạng
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
456 với hình dạng

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
44

Ví dụ: giả sử chúng tôi muốn thêm 4 phần tử phân tán vào tenxơ hạng 1 thành 8 phần tử. Trong Python, bản cập nhật đó sẽ như thế này

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
49

Sau khi cập nhật

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
477 sẽ như thế này

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
80

Xem

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
457 để biết thêm chi tiết về cách cập nhật lát cắt

Args
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068Các chỉ số được sử dụng trong hoạt động.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
454Các giá trị được sử dụng trong hoạt động.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 482

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
81

Áp dụng phép gán thưa thớt cho các giá trị hoặc lát riêng lẻ trong Biến

Biến có thứ hạng

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
442 và
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068 là một
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 của thứ hạng
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
445

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068 phải là tensor nguyên, chứa các chỉ số vào self. Nó phải có hình dạng
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
447 trong đó
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
448

Chiều trong cùng của

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068 (có chiều dài
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
450) tương ứng với các chỉ số thành phần tử (nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
451) hoặc lát (nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
452) dọc theo chiều thứ
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
450 của chính nó

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
454 là
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 của hạng
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
456 với hình dạng

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
44

Ví dụ: giả sử chúng tôi muốn thêm 4 phần tử phân tán vào tenxơ hạng 1 thành 8 phần tử. Trong Python, bản cập nhật đó sẽ như thế này

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
83

Bản cập nhật kết quả cho v sẽ như thế này

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
84

Xem

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
457 để biết thêm chi tiết về cách cập nhật lát cắt

Args
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
068Các chỉ số được sử dụng trong hoạt động.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
454Các giá trị được sử dụng trong hoạt động.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 802

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
85

Trừ đi

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 từ biến này

Args____1042
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 được trừ khỏi biến này.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, sử dụng khóa trong quá trình vận hành.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật. Tăng______1047nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
042 không phải là
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
049

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 038

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
86

Gán

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 cho biến này

Args____1042
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
029 được gán cho biến này.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
005Nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
34, sử dụng khóa trong quá trình vận hành.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47tên của hoạt động. ReturnsBiến được cập nhật. Tăng______1047nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
042 không phải là
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
049

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 822

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
87

Ghi đè hình dạng cho biến này

Args
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
15the
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
97 đại diện cho hình dạng bị ghi đè

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 825

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
88

Tập hợp các lát cắt từ trục params theo các chỉ số

Chức năng này hỗ trợ một tập hợp con của tf. thu thập, xem tf. thu thập để biết chi tiết về cách sử dụng

Args____1068Chỉ số
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14. Phải là một trong các loại sau.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
071,
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
072. Phải nằm trong phạm vi
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
830.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47Tên cho hoạt động (tùy chọn). ReturnsA
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14. Có cùng loại với
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
067

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 834

Xem nguồn

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
89

Chuyển đổi một bộ đệm giao thức

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
16 thành một
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
50

Args____1837Tùy chọn
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
58. Tên phạm vi để loại bỏ. ReturnsMột bộ đệm giao thức
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
50 hoặc
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
45 nếu
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
16 không nằm trong phạm vi tên được chỉ định

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 003

Xem nguồn

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
00

Trả về ảnh chụp nhanh cuối cùng của biến này

Bạn thường không cần gọi phương thức này vì tất cả các op cần giá trị của biến sẽ tự động gọi nó thông qua lệnh gọi

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
843

Trả về một

v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 giữ giá trị của biến. Bạn không thể gán giá trị mới cho tenxơ này vì nó không phải là tham chiếu đến biến

Để tránh các bản sao, nếu người tiêu dùng của giá trị trả về ở trên cùng một thiết bị với biến, điều này thực sự trả về giá trị trực tiếp của biến, không phải bản sao. Các cập nhật cho biến được người tiêu dùng nhìn thấy. Nếu người tiêu dùng đang sử dụng một thiết bị khác, nó sẽ nhận được một bản sao của biến

ReturnsA
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 chứa giá trị của biến

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 846

Xem nguồn

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
01

Tính giá trị tuyệt đối của tenxơ

Cho trước một tenxơ gồm các giá trị số nguyên hoặc dấu phẩy động, thao tác này trả về một tenxơ cùng loại, trong đó mỗi phần tử chứa giá trị tuyệt đối của phần tử tương ứng trong đầu vào

Cho trước một tenxơ

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
847 của các số phức, thao tác này trả về một tenxơ loại
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
848 hoặc
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
849 là giá trị tuyệt đối của mỗi phần tử trong
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
847. Đối với một số phức \(a + bj\), giá trị tuyệt đối của nó được tính là \(\sqrt{a^2 + b^2}\)

Ví dụ

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
02
>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
03Args
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
847A
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 hoặc
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
853 thuộc loại
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
854,
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
848,
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
849,
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
071,
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
072,
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
859 hoặc
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
860.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47Tên cho hoạt động (tùy chọn). ReturnsA
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 hoặc
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
853 có cùng kích thước, loại và độ thưa thớt như
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
847, với các giá trị tuyệt đối. Lưu ý, đối với đầu vào
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
859 hoặc
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
860,
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 được trả về sẽ thuộc loại
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
848 hoặc
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
849 tương ứng

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 870

Xem nguồn

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
04

Thao tác được gọi bởi toán tử

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
871

Mục đích trong API Phương thức này được hiển thị trong API của TensorFlow để các nhà phát triển thư viện có thể đăng ký gửi cho
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
871 để cho phép nó xử lý các tenxơ tổng hợp tùy chỉnh và các đối tượng tùy chỉnh khác

Biểu tượng API không được người dùng gọi trực tiếp và xuất hiện trong tài liệu do TensorFlow tạo ra

Args______1847Vế trái của toán tử
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
874.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
875Vế phải của toán tử
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
874.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47một tên tùy chọn cho hoạt động. Trả về Kết quả của hoạt động phần tử khôn ngoan ________ 1874

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 879

Xem nguồn

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
05

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 880

Xem nguồn

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
06

Chia x / y theo từng phần tử (sử dụng ngữ nghĩa toán tử chia Python 2). (không dùng nữa)

Không dùng nữa. CHỨC NĂNG NÀY KHÔNG ĐƯỢC DÙNG. Nó sẽ được gỡ bỏ trong một phiên bản tương lai. Hướng dẫn cập nhật. Không dùng nữa để ủng hộ toán tử hoặc tf. môn Toán. chia.

Hàm này chia

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
847 và
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
875, buộc Python 2 ngữ nghĩa. Nghĩa là, nếu
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
847 và
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
875 đều là số nguyên thì kết quả sẽ là số nguyên. Điều này trái ngược với Python 3, trong đó phép chia với
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
885 luôn là số float trong khi phép chia với
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
886 luôn là số nguyên

Args
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
847
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 tử số của kiểu số thực.
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
875
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
14 mẫu số của kiểu số thực.
v = tf.Variable(1.)
v.assign(2.)
<tf.Variable .. shape=() dtype=float32, numpy=2.0>
v.assign_add(0.5)
<tf.Variable .. shape=() dtype=float32, numpy=2.5>
47Tên cho hoạt động (tùy chọn). Returns
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
892 trả về thương của x và y

Di chuyển sang TF2

Chức năng này không được dùng trong TF2. Thích sử dụng toán tử chia Tensor,

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
893 hoặc
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
894, tuân theo ngữ nghĩa của toán tử chia Python 3

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 895

Xem nguồn

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
07

So sánh hai biến yếu tố khôn ngoan cho bình đẳng

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32) temp_c temp_f Portland 17.0 62.6 Berkeley 25.0 77.0 896

Xem nguồn

>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
08

Chia

>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
892 theo nguyên tố, làm tròn về số nguyên âm nhất

Về mặt toán học, điều này tương đương với sàn(x / y). Ví dụ. tầng (8. 4/4. 0) = sàn(2. 1) = 2. 0 tầng(-8. 4/4. 0) = sàn(-2. 1) = -3. 0 Điều này tương đương với toán tử '//' trong Python 3. 0 trở lên

Note:
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
847 and
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
875 must have the same numeric type. If the inputs are floating point, the output will have the same type. If the inputs are integral, the inputs are cast to
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
848 for
>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
016 and
>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
015 and
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
849 for
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
071 and
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
          temp_c  temp_f
Portland    17.0    62.6
Berkeley    25.0    77.0
072 (matching the behavior of Numpy).

Đối tượng gán() hoạt động như thế nào?

Đối tượng. phương thức gán() chỉ sao chép các thuộc tính có thể đếm được và thuộc tính riêng từ đối tượng nguồn sang đối tượng đích . Nó sử dụng [[Get]] trên nguồn và [[Set]] trên đích, vì vậy nó sẽ gọi getters và setters. Do đó, nó gán thuộc tính, so với sao chép hoặc xác định thuộc tính mới.

Đối tượng gán có tạo tham chiếu mới không?

chỉ định. Vì vậy, sao chép một biến đối tượng sẽ tạo thêm một tham chiếu đến cùng một đối tượng .