반응형

Linear Regression 의 cost 최소화의 TensorFlow 구현(new)

X = [1, 2, 3]
Y = [1, 2, 3]

W= tf.Variable(5.0) # 말도 안되는 값을 준다.
hypothesis = X * W
gradient = tf.reduce_mean((W * X - Y) * X) * 2

cost = tf.reduce_mean(tf.square(hypothesis - Y))
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.01)

gvs = optimizer.compute_gradients(cost,[W])
apply_gradients = optimizer.apply_gradients(gvs)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
for step in range(101):
    print(step, sess.run([gradient, W,gvs]))
    sess.run(apply_gradients)

 

gvs = optimizer.compute_gradients(cost) -> gvs = optimizer.compute_gradients(cost,[W]) 으로 수정

 

참고 :

https://kswims.tistory.com/97

 

[Lec03] Linear Regression의 cost 최소화 알고리즘의 원리 설명

오늘은 'cost function을 어떻게 최소화해서 학습을 시킬 것인가'를 알아보도록 하겠다. 우리가 학습시키는 Hypothesis는 H(x) = Wx+b로 주어진다. 이걸 통해서 만들어 낼 수 있는 식 cost(W,b)는 예측값과

kswims.tistory.com

 

반응형
반응형

해결 

https://kyumdoctor.co.kr/18

 

gpu 버전 차이 때문에 나는 에러이다.

해결 방법은 두가지 이다.

 

1. nvidia-docker run 

2. docker run --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=2,3

 

 

 

 

반응형
반응형

pip install gensim

 

module 'numpy.random' has no attribute 'default_rng'

 

해결 방밥:

1. numpy 버전 올리기

conda update numpy

 

numpy 버전을 확인하고 1.17이상이여 한다.

numpy 버전 확인:

import numpy as np

np.__version__

 

 

stackoverflow.com/questions/62077194/can%C2%B4t-import-qiskit-attribute-error-in-numpy-numpy-random-has-no-attribute

 

Can´t import qiskit, attribute error in numpy: " 'numpy.random' has no attribute 'default_rng'"

I´m using Python 3 and I´m working in jupyter, when I try to import qiskit the following error is showed: --------------------------------------------------------------------------- AttributeError...

stackoverflow.com

 

2. gensim버전 다운하기

pip install -U gensim==3.7.x

반응형
반응형

1. konlpy 설치

pip install konlpy

 

2. jdk 설치

 

3. jdk를  환경 변수 추가

java_home

 

4. JPype다운

www.lfd.uci.edu/~gohlke/pythonlibs/#jpype

 

Python Extension Packages for Windows - Christoph Gohlke

by Christoph Gohlke, Laboratory for Fluorescence Dynamics, University of California, Irvine. Updated on 1 April 2021 at 00:31 UTC. This page provides 32- and 64-bit Windows binaries of many scientific open-source extension packages for the official CPython

www.lfd.uci.edu

에서 다운로드 하고 

해당 경로에 나둔다음 PIP로 설치한다. 

pip install JPype1-1.2.0-cp38-cp38-win_amd64.whl

 

반응형
반응형

assertion failed: [0] [Op:Assert] name: EagerVariableNameReuse

 

import os
os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = "true"

stackoverflow.com/questions/61200676/tensorflow2-1-invalidargumenterror-assertion-failed-0-opassert-name-eage

반응형
반응형

 

 

assertion failed: [0] [Op:Assert] name: EagerVariableNameReuse

 

 

 

인터넷 상에서 여러가지 해결책으로 나오고 있는데

tensorflow 버전을 확인 하면서 downgrade하지 않으면 upgrade등 여러가지 방법이 나온다.

 

tensorflow버전과 상관 없이 해결 방법이 있다.

오류 해결 방법:

import os
os.environ["CUDA_VISIBLE_DEVICES"] = ""

 

 

import os
os.environ["CUDA_VISIBLE_DEVICES"] = ""

이 코드를 실행하고도 같은 경우가 났을 경우에는 kernel restart하고 다시 실행 하면 된다.

gpu를 사용하지 않으면 오류를 해결할 수 있다.

반응형
반응형

 

 

오류 : No module named 'png'

 

 

해결 방법: pip install pypng

반응형
반응형

jupyter notebook 에서 pytorch mnist 다운로드시 

IProgress not found. Please update jupyter and ipywidgets

오류가 난다.

 

 

 

 

해결방법:

 

pip install ipywidgets

 

ipywidgets.readthedocs.io/en/stable/user_install.html

 

Installation — Jupyter Widgets 7.5.1 documentation

With pip pip install ipywidgets jupyter nbextension enable --py widgetsnbextension When using virtualenv and working in an activated virtual environment, the --sys-prefix option may be required to enable the extension and keep the environment isolated (i.e

ipywidgets.readthedocs.io

 

반응형

+ Recent posts