본문 바로가기

전체 글

[C++]조합 만들기 #include #include #include #include using namespace std; int comb(string order, int pos, int wish,int count,string push_order, vector &table) { if (pos > order.length()) { return 1; } if (count == wish) { cout 더보기
[Design Pattern] Decorator 예제 출처는 위에 적혀 있습니다. 연습용 예제 입니다. // Simple decorator pattern example // (c) Daniel Livingstone 2012 // CC-BY-SA #include #include using namespace std; class AbstractNPC { public: virtual void render() = 0; }; class NPC : public AbstractNPC { private: string name; public: NPC(string basename) { name.assign(basename); } NPC(char * basename) { name.assign(basename); } void render() { cout render(); } //.. 더보기
[C++]용어정리 static 변수: 클래스 내에서 공유되는 변수 class Marine { static int total_marine_num;//클래스 내부에서 선언, 선언과 동시에 초기화 불가 private: ... int Marine::total_marine_num = 0;//클래스 외부에서 초기화 필요 static 함수: 객체별로 존재하는 것이 아닌 클래스별로 존재하는 함수, 객체없이 클래스에서 자체 호출 가능 static void show_total_marine(); void Marine::show_total_marine() { std::cout 더보기
[deepLearning]CNN filter의 number, filter의 size 알아볼것 self.conv1 = layers.Conv2D(32, kernel_size=5, activation=tf.nn.relu) 에서 계수들이 의미하는 바 convolution layer를 지날때 마다 텐서의 크기가 어떻게 바뀌는지 계수들의 의미 kernel_size=5 5는 filter의 한변의 크기를 의미하며 filter는 kernel, window등이라고도 불린다. 원래 그림에서 이미지 사이즈는 7*7 이었는데 3*3인 필터랑 컨볼루션 하면 (7+1)-3 = 5사이즈의 이미지가 된다. 32 : number of filter 32는 filter의 개수를 의미한다. 위의 그림에서 보라색 filter 같은게 32개가 있다고 보면된다. 위의 그림에서 INPUT 이미지를 컨볼루션 하면 28*28의 이미지.. 더보기
[python] numpy 행렬 전체 출력 하는법 결론은 np.set_printoptions(threshold=np.inf, linewidth=np.inf) 해주면 된다. 텐서플로우 예제코드 스터디 중이다. from __future__ import absolute_import, division, print_function import tensorflow as tf import numpy as np num_classes = 10 num_features = 784 learning_rate = 0.01 training_steps = 1000 batch_size = 256 display_step = 50 from tensorflow.keras.datasets import mnist (x_train, y_train),(x_test, y_test) = mnist... 더보기
[tensorflow] tf.GradientTape.gradient() 계산 과정 보기 import tensorflow as tf import numpy as np rng = np.random learning_rate = 0.01 training_steps = 1000 display_step = 50 # X = np.array([3.3,4.4,5.5,6.71,6.93,4.168,9.779,6.182,7.59,2.167, # 7.042,10.791,5.313,7.997,5.654,9.27,3.1]) # Y = np.array([1.7,2.76,2.09,3.19,1.694,1.573,3.366,2.596,2.53,1.221, # 2.827,3.465,1.65,2.904,2.42,2.94,1.3]) X = np.array([3.3,1]) Y = np.array([1.7,2]) W = tf.Var.. 더보기
[tensorflow]AttributeError: 'Tensor' object has no attribute 'numpy' 해결 import tensorflow as tf #tf.enable_eager_execution() hello = tf.constant(10) print(hello) print(hello.numpy()) 간단한 코드인데 AttributeError: 'Tensor' object has no attribute 'numpy' 가 나오면 서 오류가 난다. 텐서 값도 출력해보면 주석처리된 tf.enable_eager_execution() 를 추가하면 "기존 그래프 기반 방식에서 벗어나 그래프 생성 없이 연산을 즉시 실행하는 명령형 프로그래밍 환경"으로 바뀐다고한다. 아직은 정확히 무슨 오류고 어떻게 해결된건지는 모르겠어서 차후에 알게되면 추가로 적겠다. 일단 해결은 된다. 더보기
[Algorithm] DP-2 동적 테이블을 작성하는 Knapsack 예제풀이이다. [Algorithm] DP-2 동적 테이블을 작성하는 Knapsack 예제풀이이다. https://www.acmicpc.net/problem/12865 12865번: 평범한 배낭 이 문제는 아주 평범한 배낭에 관한 문제이다. 한 달 후면 국가의 부름을 받게 되는 준서는 여행을 가려고 한다. 세상과의 단절을 슬퍼하며 최대한 즐기기 위한 여행이기 때문에, 가지고 다닐 배낭 또한 최대한 가치 있게 싸려고 한다. 준서가 여행에 필요하다고 생각하는 N개의 물건이 있다. 각 물건은 무게 W와 가치 V를 가지는데, 해당 물건을 배낭에 넣어서 가면 준서가 V만큼 즐길 수 있다. 아직 행군을 해본 적이 없는 준서는 최대 K무게까지의 배낭만 들고 다닐 수 있다. 준서가 최대한 즐거운 여행을 하기 위해 배낭에 넣을 수 있는.. 더보기