티스토리 뷰
Tensorflow에서 제공하는 tf.math.equal 함수는 입력값 두개가 같은지 다른지 비교해주는 함수이다.
기본 형태로
tf.math.equal(x, y, name=None)
형태를 취한다.
x와 y의 값을 원소별로 같은지 다른지 비교해주고 각각에 대한 True or False를 return해주는 함수이다.
예제 1)
x = tf.constant([2, 4])
y = tf.constant([2, 4])
tf.math.equal(x, y)
에 대해서는 값이 [True, True]로 나온다.
예제 2)
x = tf.constant([2,4])
y = tf.constant(2)
tf.math.equal(x, y)
에 대해서는 값이 [True, False]로 나온다.
예제 3)
x = tf.constant([2, 2])
y = tf.constant(2)
tf.math.equal(x, y)
에 대해서는 값이 [True, True] 로 나온다.
비교하는 값이 하나밖에 없을 때는 첫번째 값과 계속 비교한다,
그러나 2개와 3개를 비교하려고 하면 incompatible shape error가 발생한다(예제 4).
예제 4)
x = tf.constant([2, 3, 2])
y = tf.constant([3, 2])
tf.math.equal(x, y)
(error massage)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [3] vs. [2] [Op:Equal]
'이것저것 자료 > Python' 카테고리의 다른 글
[python library] opencv 설치하기 (0) | 2021.08.09 |
---|---|
[python] Tensorflow tf.math.argmax 함수 (0) | 2021.08.04 |
[python library] numba install error (0) | 2021.07.27 |
[python module] scipy 설치 (0) | 2021.07.27 |
[Tensorflow] GPU 대신 XLA_GPU만 잡힐 때 (0) | 2021.07.27 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- pytorch
- 프로그래머스
- BFS
- shellscript
- version
- numpy
- matplotlib
- 이것이코딩테스트다
- 최소신장트리
- dfs
- LGSVL
- 백준
- 설치
- 다익스트라
- docker
- 코딩테스트
- 카카오
- error
- 설치하기
- notfound
- torchscript
- torch
- 동적프로그래밍
- PIP
- CUDA
- tensorflow
- n과m
- 파이썬
- Python
- 백트래킹
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함