[LA] tf.linalg.solve 로 linear system 의 solution 구하기.

2022. 9. 1. 13:31·.../Math
728x90
728x90

David C. Lay의 Linear Algebra의 1장의 예제를 tensorflow로 확인.

colab으로 간단히 확인 가능함.

import tensorflow as tf
import numpy as np

A = np.array([
    [1 ,-2, 1],
    [0 , 2,-8],
    [-4, 5, 9]
], dtype=float)

cmtx = tf.constant(A)

b = np.array([0,8,-9],dtype=float)

# tf.constant 를 이용. (1)
# b = b.reshape(-1,1)
# bvec = tf.constant(b)

# tf.constant 를 이용. (2)
bvec = tf.constant(b, shape=(3,1))

# tf.Varialbe을 이용.
# b = b.reshape(-1,1)
# bvec = tf.Variable(b, shape=(3,1))

solution = tf.linalg.solve(cmtx,bvec)
solution

결과는 다음과 같음.

<tf.Tensor: shape=(3, 1), dtype=float64, numpy=
array([[29.],
       [16.],
       [ 3.]])>

References

https://www.tensorflow.org/api_docs/python/tf/linalg/solve

 

tf.linalg.solve  |  TensorFlow v2.9.1

Solves systems of linear equations.

www.tensorflow.org

https://gist.github.com/dsaint31x/88ec4f787feba7df702c89b0cb6fd9ae

 

LA_Ch01_01_Ex.ipynb

LA_Ch01_01_Ex.ipynb. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

 

728x90

'... > Math' 카테고리의 다른 글

[LA] Set of Real-valued Functions defined on a set of real number : Vector Space  (2) 2022.09.30
[LA] sympy로 Reduced Row Echelon Matrix 구하기.  (0) 2022.09.01
[LA] Data Types (or The Types of Variable)  (0) 2022.09.01
[LA] Introduction of Linear Algebra  (0) 2022.09.01
[Math] Definition, Proposition, Axiom, and Theorem  (0) 2022.09.01
'.../Math' 카테고리의 다른 글
  • [LA] Set of Real-valued Functions defined on a set of real number : Vector Space
  • [LA] sympy로 Reduced Row Echelon Matrix 구하기.
  • [LA] Data Types (or The Types of Variable)
  • [LA] Introduction of Linear Algebra
dsaint31x
dsaint31x
    반응형
    250x250
  • dsaint31x
    Dsaint31's blog
    dsaint31x
  • 전체
    오늘
    어제
    • 분류 전체보기 (787)
      • Private Life (15)
      • Programming (206)
        • DIP (116)
        • ML (35)
      • Computer (120)
        • CE (54)
        • ETC (33)
        • CUDA (3)
        • Blog, Markdown, Latex (4)
        • Linux (9)
      • ... (368)
        • Signals and Systems (115)
        • Math (176)
        • Linear Algebra (33)
        • Physics (43)
        • 인성세미나 (1)
      • 정리필요. (61)
        • 의료기기의 이해 (6)
        • PET, MRI and so on. (7)
        • PET Study 2009 (1)
        • 방사선 장해방호 (5)
        • 방사선 생물학 (3)
        • 방사선 계측 (9)
        • 기타 방사능관련 (3)
        • 고시 (9)
        • 정리 (18)
      • RI (0)
      • 원자력,방사능 관련법 (2)
  • 블로그 메뉴

    • Math
    • Programming
    • SS
    • DIP
  • 링크

    • Convex Optimization For All
  • 공지사항

    • Test
    • PET Study 2009
    • 기타 방사능관련.
  • 인기 글

  • 태그

    linear algebra
    Programming
    opencv
    Probability
    Term
    SS
    인허가제도
    cv2
    SIGNAL
    signals_and_systems
    numpy
    ML
    signal_and_system
    fourier transform
    random
    Optimization
    function
    Python
    Vector
    math
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dsaint31x
[LA] tf.linalg.solve 로 linear system 의 solution 구하기.
상단으로

티스토리툴바