본문 바로가기
반응형

튜토리얼6

[Keras] 01 - Keras 시작하기 Keras 를 활용한 간단한 ML 기초입니다.¶ 기본적으로 Machine Learning 은 최종 Target 을 맞추기 위해 적당히 선형으로 결합된 network graph를 먼저 설계하고 그 graph의 weight 에 해당하는 값을 데이터에 맞추어 자동으로 튜닝하는 내용으로 이루어져 있습니다. 보통 이 tune 을 해주는 프로그램으로 유명한게 tensorflow / pytorch 등이 있으며 이번에 소개해드릴 keras는 tensorflow (또는 theano) 를 backend 로 하여 돌아가는 일종의 wrapper 입니다. 아래는 임의의 X1~X5 의 변수를 이용해서 설계된 Y 를 맞추는 회귀 예제입니다. -- by m.song 7/10 In [ ]: # 필수 라이브러리 로드 # Tensorfl.. 2023. 10. 8.
Perl Tutorial - 4. Count Lines 3 앞의 예제를 좀 더 깔끔하게 모듈화 시켜본다. #!/usr/bin/perl use 5.18.0; use warnings; use IO::File; main(@ARGV); sub main { my $filename = shift || "file.txt"; my $count = countlines( $filename ); say "there are $count lines in $filename"; } sub countlines { my $filename = shift; error("missing file") unless $filename; my $fh = IO::File->new( $filename , "r") or error("Cannot open $filename ($!)\n"); my $count = .. 2020. 12. 31.
Perl tutorial - 3. Count lines 2 전의 튜토리얼을 통해서 파일을 읽고, 행의 갯수를 새 보았는데 겨우 행의 갯수를 세기 위해서 모든 text 파일을 읽어서 저장하는 것은 사실 비효율적인 일이다. 즉 파일의 contents 는 필요없고 단순히 몇 line 으로 이루어져 있는 지를 확인하는 보다 직관적인 튜토리얼은 다음과 같다. #!/usr/bin/perl use 5.18.0; use warnings; use IO::File; ##library for io control my $filename = "file.txt"; #declear var my $fh = IO::File->new($filename, "r"); if( ! $fh ){ print("Cannot open $filename ($!)\n"); exit } my $count = 0;.. 2020. 12. 31.
Perl Tutorial - 2. Count Lines #!/usr/bin/perl use 5.18.0; use warnings; my $filename = "linesfile.txt"; open(FH, $filename); # open the file my @lines = ; # read the file close(FH); # close the file my $count = scalar @lines; # the number of lines in the file say "There are $count lines in $filename"; 지난번에 이어, 이번에는 파일 입출력과 관련된 튜토리얼이다. 먼저 Perl의 변수형은 int, float, string 등으로 데이터 타입에 따라 정의되는 다른 언어들과 달리 데이터의 형식 (단수, 복수 등)에 따라 scal.. 2020. 12. 28.
반응형