목록분류 전체보기 (20)
uos-machine-learning
정점이 N개일 때 최단 경로는 항상 최대 N-1개로 구성되므로 N단계에서 최단경로가 갱신되면 음수로 되어있는 사이클이 존재한다. #include #include #include #include #include using namespace std; struct point{ int from; int to; int cost; }; int n, m, w; const int inf = 0x1fffffff; int main(){ int T; cin >> T; while (T--){ cin >> n; cin >> m; cin >> w; vector group; int dist[501]; for (int i = 1; i > u >> v >> x; group.push_back({ u, v, x }); group.push..
가중치에 음수가 있으므로 다익스트라가 아닌 벨만포드 알고리즘을 써야 한다. -10000 m; group.resize(m); for (int i = 0; i > group[i].now; cin >> group[i].next; cin >> group[i].cost; } for (int i = 1; i

https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/r2/tutorials/generative/style_transfer.ipynb#scrollTo=eqxUicSPUOP6 Google Colaboratory colab.research.google.com Tensor flow 2.0 alpha 버전 Neural Sytle Transfer Notebook 리뷰입니다. Neural Style Transfer란? content 이미지가 style reference 이미지로 그려진 것과 같이 만들어주는 알고리즘입니다. 아래 거북이 사진(content)과 스타일 사진(style reference)을 통해 새로운 이미지를 만든 것을..
인접행렬이 주어졌을 때 모든 정점 i, j 에 대하여 i에서 j로 가는 경로가 있는지 없는지 판단 For문으로 모든 정점의 추이관계를 찾아주면 된다. #include #include using namespace std; int d[100][100]; int main() { int n; cin >> n; for (int i=0; i d[i][j]; } } for (int k=0; k

1. PSNR(Peak Signal-to-Noise Ratio) 정 의 : 신호가 가질 수 있는 최대전력 잡음비 # 케라스 psnr 평가 metric 예시 def PSNR(y_true, y_pred): return tf.image.psnr(y_true, y_pred, max_val=1.0) 2. SSIM(Structural Similarity Index) 정 의 : 압축 및 변환에 의해 발생하는 왜곡에 대하여 원본 영상에 대한 유사도를 측정하는 방법 def SSIM(y_true, y_pred): return tf.image.ssim(y_true, y_pred, max_val=1.0)
dist[i][j] 는 i->j로 가는 최소 비용, 따라서 사이클은 dist[i][j] + dist[j][i]이다. 이중 최소값을 찾으면 된다. #include #include #include #include #include using namespace std; int N, M; vector graph; int answer[401][401]; vector dijkstra(int src){ vector dist(N + 1, INT_MAX); priority_queue q; q.push(make_pair(0, src)); dist[src] = 0; while (!q.empty()){ int nowcost = -q.top().first; int now = q.top().second; q.pop(); if (d..
1-> V1-> V2 -> N 1-> V2 -> V1 ->N 다익스트라 세번을 구한 뒤 화살표에 해당하는 최소비용을 각각 구해준다. #include #include #include #include using namespace std; int n, m; vector graph; int inf = 100000000; vector dijkstra(int src){ vector dist(n + 1, inf); priority_queue mq; mq.push(make_pair(0, src)); dist[src] = 0; while (!mq.empty()){ int now = mq.top().second; int cost = -mq.top().first; mq.pop(); if (dist[now] < cost){ ..
다익스트라에서 dist 배열을 갱신할 때 마다 parent 배열에 연결된 노드를 저장하면 된다. #include #include #include #include #define INF 0x7fffffff; using namespace std; vector adj[1001]; // 최소 비용 저장 int dist[1001]; // 최소 비용을 갖는 부모 저장 int parent[1001]; // 경로에 포함된 도시 경로 개수 int cnt; bool visited[1001]; void dijkstra(int root) { dist[root] = 0; priority_queue q; q.push({ 0, root }); while (!q.empty()) { int now = q.top().second; q.p..