PyTorch

Similar documents
K&R2 Reference Manual 번역본

PowerPoint Presentation

슬라이드 1

chap10.PDF

쉽게 풀어쓴 C 프로그래밍

슬라이드 1

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout << " 양수입력 : "; cin >> *p; if (*p <= 0) cout << " 양수를입력해야합니다 " << endl; return; 동적할

금오공대 컴퓨터공학전공 강의자료

<4D F736F F F696E74202D2036C0CFC2B05FB0B4C3BCC1F6C7E2C7C1B7CEB1D7B7A1B9D62E707074>

Microsoft PowerPoint - additional01.ppt [호환 모드]

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

PowerPoint Presentation

The C++ Programming Language 4 장타입과선언 4.11 연습문제 Hello,world! 프로그램을실행시킨다. 프로그램이컴파일되지않으면 B3.1 을참고하자. #include<iostream> //#include 문, 헤더파일, 전처리지시

설계란 무엇인가?

Microsoft PowerPoint - C++ 5 .pptx

Slide 1

Microsoft PowerPoint - chap12-고급기능.pptx

윤성우의 열혈 TCP/IP 소켓 프로그래밍

PowerPoint 프레젠테이션

PowerPoint Template

PowerPoint 프레젠테이션

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning

C++ Programming

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Chapter #01 Subject

쉽게 풀어쓴 C 프로그래밍

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

17장 클래스와 메소드

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

C# Programming Guide - Types

4 장클래스와객체 클래스와객체 public과 private 구조체와클래스객체의생성과생성자객체의소멸과소멸자생성자와소멸자의호출순서디폴트생성자와디폴트소멸자멤버초기화멤버함수의외부정의멤버함수의인라인함수선언 C++ 프로그래밍입문

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

금오공대 컴퓨터공학전공 강의자료

C++ Programming

Microsoft PowerPoint - ch10 - 이진트리, AVL 트리, 트리 응용 pm0600

Design Issues

본 강의에 들어가기 전

Microsoft PowerPoint - CSharp-10-예외처리

PowerPoint 프레젠테이션

Microsoft PowerPoint - Chapter 6.ppt

Microsoft PowerPoint - Java7.pptx

example code are examined in this stage The low pressure pressurizer reactor trip module of the Plant Protection System was programmed as subject for

JVM 메모리구조

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

adfasdfasfdasfasfadf

<4D F736F F F696E74202D20C1A63132B0AD20B5BFC0FB20B8DEB8F0B8AEC7D2B4E7>

Microsoft PowerPoint - chap03-변수와데이터형.pptx


2002년 2학기 자료구조

PowerPoint 프레젠테이션

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a

gnu-lee-oop-kor-lec06-3-chap7

Page 2 of 5 아니다 means to not be, and is therefore the opposite of 이다. While English simply turns words like to be or to exist negative by adding not,

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

Microsoft PowerPoint - [2009] 02.pptx

Contents. 1. PMD ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 2. Metrics ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 3. FindBugs ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 4. ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ

본문01

PowerPoint Template

Eclipse 와 Firefox 를이용한 Javascript 개발 발표자 : 문경대 11 년 10 월 26 일수요일

11장 포인터

Microsoft PowerPoint - 09-Object Oriented Programming-3.pptx

Chapter 4. LISTS

KNK_C_05_Pointers_Arrays_structures_summary_v02

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++,

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

02장.배열과 클래스

intro

Microsoft PowerPoint - additional03.ppt [호환 모드]

예제 2) Test.java class A intvar= 10; void method() class B extends A intvar= 20; 1"); void method() 2"); void method1() public class Test 3"); args) A

Microsoft PowerPoint - chap10-함수의활용.pptx

ThisJava ..

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

쉽게 풀어쓴 C 프로그래밍

Microsoft PowerPoint - 08-C-App-19-Quick-Preprocessor

PowerPoint 프레젠테이션

Microsoft PowerPoint - ch07 - 포인터 pm0415

C++-¿Ïº®Çؼ³10Àå

Page 2 of 6 Here are the rules for conjugating Whether (or not) and If when using a Descriptive Verb. The only difference here from Action Verbs is wh

Microsoft PowerPoint - chap05-제어문.pptx

Microsoft PowerPoint - additional06.ppt [호환 모드]

Lab 3. 실습문제 (Single linked list)_해답.hwp

untitled

untitled

Microsoft PowerPoint - 8ÀÏ°_Æ÷ÀÎÅÍ.ppt

chap 5: Trees

1장. 유닉스 시스템 프로그래밍 개요

학습목표 함수프로시저, 서브프로시저의의미를안다. 매개변수전달방식을학습한다. 함수를이용한프로그래밍한다. 2

슬라이드 1

Microsoft PowerPoint - Chapter 1-rev

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4

Microsoft PowerPoint - Chap12-OOP.ppt

Infinity(∞) Strategy

Microsoft PowerPoint - chap08-1 [호환 모드]

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

Transcription:

I Know What You Did Last Faculty : C++ Coding Standard ISL Lab Seminar Hansol Kang

Contents Introduction Summary Rule of thumb Naming Header file Conditional Statement Comment

Introduction (Coding Standard) if (a > a_1 && b < b_1 && c < c_1 d>d_1) Readability int abc(int a, int b) { Do something Do you really need to make it a function? Coding Convention Optimization Maintenance 2

Rule of Thumb by 포프 Readability first (your code should be your documentation most of the time) Crash/Assert early. Don't wait until the worst case happens to make the crash condition. Follow IDE's auto formatted style unless you have really good reasons not to do so. (Ctrl + K + D in VC++) Learn from existing code 3

Naming Camel case : 각단어의첫문자를대문자로표기하며, 맨처음문자는소문자로표기.( 대문자로단어를구분 ) kurtcobain Pascal case : 첫단어를대문자로표기. KurtCobain Snake case : 단어사이를 underscore 로구분하여표기. kurt_cobain Hungarian notation : 데이터타입을의미하는접두어를사용하여표기. strkurtcobain 지양하는추세. Why? 1. IDE의발달로데이터타입을표기할필요 x 2. 변수의의미를파악하는것이더욱중요 4

Google C++ Naming(General Naming Rules) 함수이름, 변수이름, 파일이름은약어를피하고서술적으로작성. int price_count_reader; int num_errors; int num_dns_connections; int lstm_size; // No abbreviation. // "num" is a widespread convention. // Most people know what "DNS" stands for. // "LSTM" is a common machine learning abbreviation. int n; int nerr; int n_comp_conns; int wgc_connections; int pc_reader; int cstmr_id; // Meaningless. // Ambiguous abbreviation. // Ambiguous abbreviation. // Only your group knows what this stands for. // Lots of things can be abbreviated "pc". // Deletes internal letters. 가능하다면상세한이름을사용할것. 글자길이를줄이는것보다새로읽는사람이즉시이해하는것이더중요. 5

Google C++ Naming(File Names) 파일이름은모두소문자이어야하고, underscore 나 dash 로단어사이를연결함. 반드시 underscore 일필요는없으며, 프로젝트에서사용하던관례를따름. my_useful_class.cc my-useful-class.cc myusefulclass.cc url_table.h url_table.cc url_table-ini.h 클래스선언클래스정의많은코드를포함한인라인함수 Cf. Inline function 인라인함수는대부분헤더에선언하는것을기본으로그길이가너무긴경우 inl.h 로따로작성할것. 인라인함수는함수가작을때만 (10 라인이나그이하 ) 사용할것. 인라인함수의무분별한사용은지양. inline int max_limit(double x){ return x>255? 255 : (int)x; 6

Google C++ Naming(Type Names) 타입이름은대문자로시작하며 underscore 없이단어마다첫글자로대문자를사용. 클래스, 구조체, typedef, 열거형을포함한모든타입에대해같은규칙이적용. // Class and structure class UrlTable { struct UrlTableProperties { // Enumerated type enum UrlTableErrors { 7

Google C++ Naming(Variable Names) 변수이름은모두소문자로작성하며단어사이에 underscore 를사용. 클래스멤버변수는이름끝에 underscore 를사용. string table_name; // OK - uses underscore. string tablename; // OK - all lowercase. string tablename; // Bad - mixed case. 구조체는보통변수처럼사용. struct UrlTableProperties { string name; int num_entries; Cf. structs vs. classes class TableInfo { private: string table_name_; // OK - underscore at end. string tablename_; // OK. ; C++ 에서 struct 와 class 키워드는거의똑같이동작. 데이터를나르는수동적인객체의경우에만 struct 를사용하며, 그외의모든경우에는 class 를사용. structs 는멤버의값을읽고쓰는것이외의어떤기능도허용하지않음. 필드의접근 / 변경은메서드호출이아닌직접필드에접근하는방식으로작성할것. 더많은기능이필요하다면 class 가적당하며불확실한경우 class 로만들것. 8

Google C++ Naming(Constant Names) k 로시작하는대소문자가섞인이름을사용. const int kdaysinaweek = 7; 지역변수인지, 전역변수인지, 클래스의일부인지와상관없이모든컴파일시점상수들은다른변수들과조금다른이름규칙을사용. k 로시작하여매단어의첫글자를대문자로사용. 9

Google C++ Naming(Function Names) 일반함수들은대소문자가섞인방식을사용. accessors 와 mutators 는해당하는변수의이름과같은것을사용. AddTableEntry() DeleteUrl() OpenFileOrDie() crash 가발생할수있는함수 함수이름은대문자로시작하여각단어의첫글자를대문자로쓰고, underscore 는사용하지않음. 함수의실행중 crash 가발생할수있다면함수의이름뒤에 OrDie 를붙인다. 10

Google C++ Naming(Function Names cont.) accessors 와 mutators (get 과 set 함수 ) 는접근또는변경을하려는변수의이름과일치하는이름을사용. class MyClass { public:... int num_entries() const { return num_entries_; void set_num_entries(int num_entries) { num_entries_ = num_entries; private: ; int num_entries_; 11

Google C++ naming(macro names) 일반적으로매크로는사용하지않는것이좋으며, 절대적으로필요하다면대문자와 underscore 로작성. #define ROUND(x)... #define PI_ROUNDED 3.0 12

Google C++ Header Files(The #defile Guard) 모든헤더파일은여러번포함되지않기위해 #define 가드를사용. 유일성을보장하기위해 #define 가드는프로젝트의소스트리의절대경로에기반함. <PROJECT>_<PATH>_<FILE>_H_ 으로작성 예를들어프로젝트에 foo/src/bar/baz.h 파일이있다면 foo 는아래와같은가드를가져야함. #ifndef FOO_BAR_BAZ_H_ #define FOO_BAR_BAZ_H_... #endif // FOO_BAR_BAZ_H_ 13

Google C++ Header Files(Names and Order of Includes) 가독성을높이고숨겨진종속성을피하기위해서일관된순서를사용. 모든프로젝트의헤더파일은디렉터리단축표시인. ( 현재디렉터리 ) 이나.. ( 부모디렉터리 ) 을사용하지않고프로젝트의소스디렉터리의하위요소로나열. 예를들어 google-awesome-project/src/base/logging.h 는아래와같이 #include 되어야함. #include "base/logging.h" 예를들어 dir2/foo2.h 에있는것들을구현하거나테스트하기위한 dir/foo.cc 나 dir/foo_test.cc 를작성시아래의순서대로작성할것. 1. dir2 / foo2.h 2. C 시스템파일 3. C++ 시스템파일 4. 다른라이브러리의.h 파일 5. 현재프로젝트의.h 파일 14

Google C++ Header Files(Names and Order of Includes cont.) 예를들면 google-awesome-project/src/foo/internal/fooserver.cc 의 include 들은아래와같이작성할수있음. #include "foo/public/fooserver.h" // Appropriate location #include <sys/types.h> #include <unistd.h> #include <hash_map> #include <vector> #include "base/basictypes.h" #include "base/commandlineflags.h" #include "foo/public/bar.h" 15

Conditional Statement 조건문에서인수는비교하고자하는대상을왼쪽에배치할것. 당신의나이 가 10 보다큰가? 10 이 당신의나이 보다작은가? If (received < expected) if (received > expected) //good //bad 부정이아닌긍정을, 간단한것을, 흥미로운것을먼저처리할것. if (a == b) { else { if (a!= b) { else { 16

Conditional Statement 조건이길어질때리팩토링해서사용할것. if ( 복잡하고길고어렵고아무튼그런조건문 1 && 복잡하고길고어렵고아무튼그런조건문 2 복잡하고길고어렵고아무튼그런조건문 3) bool disconnected = 복잡하고길고어렵고아무튼그런조건문 1 && 복잡하고길고어렵고아무튼그런조건문 2 복잡하고길고어렵고아무튼그런조건문 3; if (disconnected) 17

Conditional Statement 삼항연산자를적절히사용할것. time_str += (hour >= 12)? "pm" : "am"; return exponent >= 0? mantissa*(1 << exponent) : mantissa / (1 << -exponent); if (hour >= 12) { time_str += "pm"; if (exponent >= 0) { return mantissa*(1 << exponent); else { time_str += "am"; else { retun mantissa / (1 << -exponent); 18

Comment 생각을기록하고나올것같은질문을예측할것. 또한코드의결함을설명하는것을두려워하지말것. TODO FIXME HACK XXX : 아직하지않은일 : 오작동을일으킨다고알려진코드 : 아름답지않은해결책 : 위험한것. 큰문제가있는경우 //TODO: 에디트박스숫자이외에입력방지 ( 完 ) //TODO: 에디트박스숫자길이제한. //TODO: 사이즈줄인것과원본을따로관리하여, 나중에비디오저장이가능하도록함. //HACK: 현재 1 번영상최적화. 19

Comment 모호한네이밍에는주석을달지말고네이밍을수정할것. // 반환하는항목의수나전체바이트수와같다. //Request 가정하는대로 Reply 에일정한한계를적용한다. void CleanReply(Request request, Reply reply); //'reply 이 cont/byte/ 등과같이 'request' 가정하는한계조건을만족시키도록한다. void EnforceLimitsFromRequest(Request request, Reply reply); 20

Summary 모든네이밍은약어사용을피하고서술적으로작성할것. 가독성좋게조건문을작성할것. 코드를수정하는것을최우선으로하고, 주석은반드시필요한경우에만작성할것. 21

Future Work Paper Review Proposed Model Tools Mathematical Study Others Vanilla GAN SpyGAN(about depth) Document Linear algebra Level Processor DCGAN Programming Probability and statistics Coding Standard LS GAN PyTorch Information theory Ice Propagation BEGAN Python executable & UI Pix2Pix Cycle GAN 22

Reference [1] 포프 C++ Coding Standards (https://docs.google.com/document/d/1ct8epgmxe0eopehvwufmbhg4tjr5kumcovkr5irqzmo/edit#heading=h.r2n9mhxbh2gg) [2] Google C++ Style Guide (Original) (https://google.github.io/styleguide/cppguide.html) [3] Google C++ Style Guide (Translated) (http://jongwook.kim/google-styleguide/trunk/cppguide.xml) [4] 읽기좋은코드가좋은코드다 (https://www.slideshare.net/e2goon/ss-33769330) [5] [ 코딩원칙?] if문. 그외가독성을올리자. (https://blog.naver.com/soguns/120139779253) [6] 무조건 if for 문에 { 를써야하는가... (http://www.gamecodi.com/board/zboard.php?id=gamecodi_talkdev&no=3727) [7] [ 읽기좋은자바스크립트코딩기법 ] 문장과표현식 ( 조건문과반복문 ) (https://jojoldu.tistory.com/6) 23

& 24

Appendix { 써야하는가? 붙여야하는가? if (condition) { dosomething(); else { dosomethingelse(); if (condition) { dosomething(); else { dosomethingelse(); 경험상으로 { 가엉켜서컴파일에러나런타임에러가발생해시간을낭비. IDE가자동으로들여쓰기해주는간단한 if for에서에러를낸적은없음. 안정성이라면세계제일이라는 NASA의표준코드 Style ASI 25