Chúng tôi biết rằng hầu hết các ứng dụng phải đối phó với một số lượng lớn các bộ dữ liệu. Do đó, một chức năng không tối ưu không tính đến có thể trở thành một nút cổ chai lớn trong thuật toán của bạn và có thể kết quả vào một mô hình mất nhiều thời gian để chạy. Để đảm bảo rằng mã có hiệu quả tính toán, chúng tôi sẽ sử dụng vector hóa.
Độ phức tạp về thời gian trong việc thực hiện bất kỳ thuật toán nào là rất quan trọng khi quyết định liệu một ứng dụng có đáng tin cậy hay không. Để chạy một thuật toán lớn trong thời gian tối ưu có thể là rất quan trọng khi nói đến ứng dụng đầu ra thời gian thực. Để làm như vậy, Python có một số hàm toán học tiêu chuẩn cho các hoạt động nhanh trên toàn bộ mảng dữ liệu mà không phải viết các vòng lặp. Một trong những thư viện như vậy có chứa chức năng như vậy là Numpy. Hãy để xem làm thế nào chúng ta có thể sử dụng chức năng tiêu chuẩn này trong trường hợp vector hóa.numpy. Let’s see how can we use this standard function in case of vectorization.
Vectorization là gì? Vectorization được sử dụng để tăng tốc mã Python mà không cần sử dụng vòng lặp. Sử dụng một chức năng như vậy có thể giúp giảm thiểu thời gian chạy của mã một cách hiệu quả. Các hoạt động khác nhau đang được thực hiện trên các vectơ như sản phẩm DOT của các vectơ còn được gọi là sản phẩm vô hướng vì nó tạo ra các sản phẩm bên ngoài, đầu ra dẫn đến ma trận vuông có chiều dài x chiều dài của vectơ, phần tử khôn ngoan tạo ra sản phẩm Phần tử của cùng một chỉ số và kích thước của ma trận vẫn không thay đổi.
Vectorization is used to speed up the Python code without using loop. Using such a
function can help in minimizing the running time of code efficiently. Various operations are being performed over vector such as dot product of vectors which is also known as scalar product as it produces single output, outer products which results in square matrix of dimension equal to length X length of the vectors, Element wise multiplication which products the element of same indexes and dimension of the matrix remain unchanged.
Chúng ta sẽ thấy các phương pháp cổ điển tốn nhiều thời gian hơn so với việc sử dụng một số hàm tiêu chuẩn bằng cách tính thời gian xử lý của chúng.
Bên ngoài [A, B]: Tính toán sản phẩm bên ngoài của hai vectơ.Multiply [A, B]: Sản phẩm ma trận của hai mảng.DOT [A, B]: Sản phẩm chấm của hai mảng.Zeros [[n, m]]: Trả về một ma trận có hình dạng và loại đã cho, chứa đầy zeros.process_time []: Trả về giá trị [tính theo giây phân đoạn] của tổng của hệ thống và thời gian CPU của người dùng của quy trình hiện tại. Nó không bao gồm thời gian trôi qua trong khi ngủ. Compute the outer product of two vectors.
multiply[a, b]: Matrix product of two arrays.
dot[a, b]: Dot product of two arrays.
zeros[[n, m]]: Return a matrix of given shape and type, filled with zeros.
process_time[]: Return the value [in fractional seconds] of the sum of the system and user CPU time of the current process. It does not include time elapsed during sleep.
Sản phẩm DOT: Sản phẩm DOT là một hoạt động đại số trong đó hai vectơ có độ dài bằng nhau đang được nhân sao cho nó tạo ra một số duy nhất. Sản phẩm chấm thường được gọi là sản phẩm bên trong. Sản phẩm này dẫn đến một số vô hướng. Hãy cùng xem xét hai ma trận A và B có cùng chiều dài, sản phẩm DOT được thực hiện bằng cách sử dụng phép chuyển đổi ma trận đầu tiên và sau đó nhân ma trận toán học của A [chuyển đổi A] và B được theo dõi như trong hình bên dưới.
Dot product is an algebraic operation in which two equal length vectors are being multiplied such that it produces a single number. Dot Product often called as inner product. This product results in a scalar number. Let’s consider two matrix a and b of same length, the dot product is done by taking the
transpose of first matrix and then mathematical matrix multiplication of a’[transpose of a] and b is followed as shown in the figure below.
Biểu diễn hình ảnh của sản phẩm DOT -
Dưới đây là mã Python:
import
time
import
numpy
import
array
a
____10
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms1
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms2
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms4
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms5
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms7
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms9
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms0
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms1
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms2
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms1
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms2
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms4
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms5
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms7
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms9
import
4import
5Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms0
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms1
import
8import
9
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
1time
2
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
4time
5outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms4
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms5
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms7
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
import
1import
2import
3time
2import
5
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
import
7import
8 import
9numpy
0
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
1numpy
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
numpy
5import
5 numpy
7numpy
8numpy
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
import
1 import
5 numpy
7outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8__
array
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
1array
6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
array
8array
9____10 time
1
numpy
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
a
4import
5numpy
7a
7Các
Output:
dot_product = 833323333350000.0 Computation time = 35.59449199999999ms n_dot_product = 833323333350000 Computation time = 0.1559900000000225ms
& nbsp; Sản phẩm bên ngoài: Sản phẩm tenxơ của hai vectơ tọa độ được gọi là sản phẩm bên ngoài. Hãy cùng xem xét hai vectơ A và B với kích thước
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms12 và
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms13 Sau đó, sản phẩm bên ngoài của vectơ dẫn đến một ma trận hình chữ nhật là
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms14. Nếu hai vectơ có cùng kích thước thì ma trận kết quả sẽ là một ma trận vuông như trong hình.
Outer Product:
The tensor product of two coordinate vectors is termed as Outer product. Let’s consider two vectors a and b with dimension
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms12 and
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms13 then the outer product of the vector results in a rectangular matrix of
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms14. If two vectors have same dimension then the resultant matrix will be a square matrix as shown in the figure.
Biểu diễn hình ảnh của sản phẩm bên ngoài -
Dưới đây là mã Python:
import
time
import
numpy
import
array
a
____10
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms1
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms2
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms4
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms5
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms7
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms9
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms0
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms1
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms2
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms1
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms2
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms4
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms5
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms7
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms9
import
4import
5Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms0
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms1
import
8import
9
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
1time
2
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
4time
5outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms4
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms5
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms7
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
import
1import
2outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms68
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms4
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms70
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms7
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
import
1outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms75
import
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms77
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms79
import
8outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms81
numpy
0
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
1numpy
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms87
import
5 numpy
7outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms90
Các
array
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
1outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms54
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms10
array
9____10 time
1
numpy
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms87
import
5numpy
7outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms90
Các
Output:
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms
& NBSP; Phần tử Wise Sản phẩm: Nhân phần yếu tố của hai ma trận là hoạt động đại số trong đó mỗi phần tử của ma trận đầu tiên được nhân với phần tử tương ứng của nó trong ma trận sau. Kích thước của các ma trận phải giống nhau. Xử lý hai ma trận A và B, chỉ số của một phần tử trong A là I và J thì A [I, J] được nhân với B [I, J] tương ứng như trong hình bên dưới.
Element wise Product:
Element-wise multiplication of two matrices is the algebraic operation in which each element of first
matrix is multiplied by its corresponding element in the later matrix. Dimension of the matrices should be same.
Consider two matrices a and b, index of an element in a is i and j then a[i, j] is multiplied with b[i, j] respectively as shown in the figure below.
Biểu diễn hình ảnh của sản phẩm khôn ngoan -
Dưới đây là mã Python:
import
time
import
numpy
import
array
a
____10
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms1
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms24
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms4
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms5
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms7
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms50
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms0
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms1
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms2
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms1
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms24
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms4
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms5
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms7
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms50
import
4outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms9
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms0
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms1
import
8Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms70
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms56
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms50
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms60
import
9
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
1outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms4
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms5
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms6
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms7
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
import
1import
2import
3
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms86
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms79
import
8import
9numpy
0
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
1numpy
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms96
import
5 numpy
7Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms99
Các
array
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
time
1outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms54
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms0
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms10
array
9____10 time
1
numpy
3
outer_product = [[ 0. 0. 0. ..., 0. 0. 0.] [ 200. 201. 202. ..., 397. 398. 399.] [ 400. 402. 404. ..., 794. 796. 798.] ..., [ 39400. 39597. 39794. ..., 78209. 78406. 78603.] [ 39600. 39798. 39996. ..., 78606. 78804. 79002.] [ 39800. 39999. 40198. ..., 79003. 79202. 79401.]] Computation time = 39.821617ms outer_product = [[ 0 0 0 ..., 0 0 0] [ 200 201 202 ..., 397 398 399] [ 400 402 404 ..., 794 796 798] ..., [39400 39597 39794 ..., 78209 78406 78603] [39600 39798 39996 ..., 78606 78804 79002] [39800 39999 40198 ..., 79003 79202 79401]] Computation time = 0.2809480000000031ms8
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms96
import
5numpy
7Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms99
Các
Output:
Element wise Product = [ 0.00000000e+00 5.00010000e+04 1.00004000e+05 ..., 4.99955001e+09 4.99970000e+09 4.99985000e+09] Computation time = 23.516678000000013ms Element wise Product = [ 0 50001 100004 ..., 704582713 704732708 704882705] Computation time = 0.2250640000000248ms