From 7f4f06c9bc69d46ab7fc1835c51e71c589215b44 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 20:48:27 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v2.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v2.4.0...v4.5.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad7815b..be152c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer From 9bce40655f89c505b381be963b82e5e38046b4ca Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 20:48:53 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- app.json | 1 - datasets/baseballdb/README.txt | 6 +- datasets/baseballdb/core/AwardsManagers.csv | 2 +- datasets/baseballdb/core/readme2014.txt | 129 ++++++++++---------- datasets/bikes/Readme.txt | 40 +++--- datasets/biofilm.csv | 2 +- datasets/mlb_2013-2016.csv | 2 +- datasets/ship-damage.txt | 2 +- models/__init__.py | 2 +- models/feedforward.py | 28 ++--- test_gpu.py | 1 - 11 files changed, 104 insertions(+), 111 deletions(-) diff --git a/app.json b/app.json index ac89e7c..86e0906 100644 --- a/app.json +++ b/app.json @@ -5,4 +5,3 @@ } } } - diff --git a/datasets/baseballdb/README.txt b/datasets/baseballdb/README.txt index 11ca567..fb39798 100755 --- a/datasets/baseballdb/README.txt +++ b/datasets/baseballdb/README.txt @@ -10,13 +10,11 @@ Chadwick Baseball Bureau (http://www.chadwick-bureau.com), from its Register of baseball personnel. Player performance data for 1871 through 2014 is based on the -Lahman Baseball Database, version 2015-01-24, which is +Lahman Baseball Database, version 2015-01-24, which is Copyright (C) 1996-2015 by Sean Lahman. The tables Parks.csv and HomeGames.csv are based on the game logs and park code table published by Retrosheet. This information is available free of charge from and is copyrighted -by Retrosheet. Interested parties may contact Retrosheet at +by Retrosheet. Interested parties may contact Retrosheet at http://www.retrosheet.org. - - diff --git a/datasets/baseballdb/core/AwardsManagers.csv b/datasets/baseballdb/core/AwardsManagers.csv index b769870..a3daeaa 100755 --- a/datasets/baseballdb/core/AwardsManagers.csv +++ b/datasets/baseballdb/core/AwardsManagers.csv @@ -176,5 +176,5 @@ showabu99,BBWAA Manager of the Year,2014,AL,, willima04,BBWAA Manager of the Year,2014,NL,, banisje01,BBWAA Manager of the Year,2015,AL,, maddojo99,BBWAA Manager of the Year,2015,NL,, -francte01,BBWAA Manager of the Year,2016,AL,, +francte01,BBWAA Manager of the Year,2016,AL,, roberda07,BBWAA Manager of the Year,2016,NL,, diff --git a/datasets/baseballdb/core/readme2014.txt b/datasets/baseballdb/core/readme2014.txt index fd1a647..81b7557 100755 --- a/datasets/baseballdb/core/readme2014.txt +++ b/datasets/baseballdb/core/readme2014.txt @@ -37,7 +37,7 @@ README CONTENTS 2.18 AwardsPlayers table 2.19 AwardsShareManagers table 2.20 AwardsSharePlayers table -2.21 FieldingPost table +2.21 FieldingPost table 2.22 Appearances table 2.23 Schools table 2.24 SchoolsPlayers table @@ -47,7 +47,7 @@ README CONTENTS 0.1 Copyright Notice & Limited Use License -This database is copyright 1996-2015 by Sean Lahman. +This database is copyright 1996-2015 by Sean Lahman. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. For details see: http://creativecommons.org/licenses/by-sa/3.0/ @@ -62,7 +62,7 @@ at: seanlahman@gmail.com Web site: http://www.baseball1.com E-Mail : seanlahman@gmail.com -If you're interested in contributing to the maintenance of this +If you're interested in contributing to the maintenance of this database or making suggestions for improvement, please consider joining our mailinglist at: @@ -78,16 +78,16 @@ This release of the database can be downloaded in several formats. The contents of each version are listed below. MS Access Versions: - lahman2014.mdb - 2014readme.txt + lahman2014.mdb + 2014readme.txt SQL version lahman2043.sql lahman2014_tables.sql - 2014readme.txt - + 2014readme.txt + Comma Delimited Version: - 2014readme.txt + 2014readme.txt AllStarFull.csv Appearances.csv AwardsManagers.csv @@ -118,9 +118,9 @@ Comma Delimited Version: This database contains pitching, hitting, and fielding statistics for Major League Baseball from 1871 through 2014. It includes data from -the two current leagues (American and National), the four other "major" +the two current leagues (American and National), the four other "major" leagues (American Association, Union Association, Players League, and -Federal League), and the National Association of 1871-1875. +Federal League), and the National Association of 1871-1875. This database was created by Sean Lahman, who pioneered the effort to make baseball statistics freely available to the general public. What @@ -139,7 +139,7 @@ the Society for American Baseball Research who have helped us over the years. We strongly urge you to support and join their efforts. Please vist their website (www.sabr.org). -If you have any problems or find any errors, please let us know. Any +If you have any problems or find any errors, please let us know. Any feedback is appreciated ---------------------------------------------------------------------- @@ -154,7 +154,7 @@ They've beenremoved from the batting table starting with this version SchoolsPlayers has been replaced with a new table called CollegePlaying. This reflects advances in the compilation of this data, largely led by Ted Turocy. The old table reported college attendance for major league -players by listing a start date and end date. The new version has a +players by listing a start date and end date. The new version has a separate record for each year that a player attended. This allows us to better account for players who attended multiple colleges or skipped a season, as well as to identify teammates. @@ -164,28 +164,28 @@ skipped a season, as well as to identify teammates. 1.3 Acknowledgements Much of the raw data contained in this database comes from the work of -Pete Palmer, the legendary statistician, who has had a hand in most -of the baseball encylopedias published since 1974. He is largely +Pete Palmer, the legendary statistician, who has had a hand in most +of the baseball encylopedias published since 1974. He is largely responsible for bringing the batting, pitching, and fielding data out of the dark ages and into the computer era. Without him, none of this -would be possible. For more on Pete's work, please read his own +would be possible. For more on Pete's work, please read his own account at: http://sabr.org/cmsfiles/PalmerDatabaseHistory.pdf -Three people have been key contributors to the work that followed, first -by taking the raw data and creating a relational database, and later +Three people have been key contributors to the work that followed, first +by taking the raw data and creating a relational database, and later by extending the database to make it more accesible to researchers. -Sean Lahman launched the Baseball Archive's website back before +Sean Lahman launched the Baseball Archive's website back before most people had heard of the world wide web. Frustrated by the -lack of sports data available, he led the effort to build a -baseball database that everyone could use. Baseball researchers +lack of sports data available, he led the effort to build a +baseball database that everyone could use. Baseball researchers everywhere owe him a debt of gratitude. Lahman served as an associate editor for three editions of Total Baseball and contributed to five editions of The ESPN Baseball Encyclopedia. He has also been active in developing databases for other sports. The work of Sean Forman to create and maintain an online encyclopedia -at "baseball-reference.com" has been remarkable. Recognized as the +at "baseball-reference.com" has been remarkable. Recognized as the premier online reference source, Forman's site provides an oustanding interface to the raw data. His efforts to help streamline the database have been extremely helpful. Most importantly, Forman has spearheaded @@ -195,7 +195,7 @@ the Baseball Databank, a forum for researchers to gather and share their work. Since 2001, these two Seans have led a group of researchers -who volunteered to maintain and update the database. +who volunteered to maintain and update the database. Ted Turocy has done the lion's share of the work to updating the main data tables since 2012, including significant imporvements to the @@ -203,18 +203,18 @@ demographic data in the master table. In his role as SABR data czar, he led the effort to document college playing stints for all major league players. Turocy also spearheads the Chadwick Baseball Bureau. For more details on his tools and services, visit: -http://chadwick.sourceforge.net/doc/index.html +http://chadwick.sourceforge.net/doc/index.html -A handful of researchers have made substantial contributions to -maintain this database over years. Listed alphabetically, they +A handful of researchers have made substantial contributions to +maintain this database over years. Listed alphabetically, they are: Derek Adair, Mike Crain, Kevin Johnson, Rod Nelson, Tom Tango, -and Paul Wendt. These folks did much of the heavy lifting, and are +and Paul Wendt. These folks did much of the heavy lifting, and are largely responsible for the improvements made since 2000. -Others who made important contributions include: Dvd Avins, -Clifford Blau, Bill Burgess, Clem Comly, Jeff Burk, Randy Cox, +Others who made important contributions include: Dvd Avins, +Clifford Blau, Bill Burgess, Clem Comly, Jeff Burk, Randy Cox, Mitch Dickerman, Paul DuBois, Mike Emeigh, F.X. Flinn, Bill Hickman, -Jerry Hoffman, Dan Holmes, Micke Hovmoller, Peter Kreutzer, +Jerry Hoffman, Dan Holmes, Micke Hovmoller, Peter Kreutzer, Danile Levine, Bruce Macleod, Ken Matinale, Michael Mavrogiannis, Cliff Otto, Alberto Perdomo, Dave Quinn, John Rickert, Tom Ruane, Theron Skyles, Hans Van Slooten, Michael Westbay, and Rob Wood. @@ -223,36 +223,36 @@ Many other people have made significant contributions to the database over the years. The contribution of Tom Ruane's effort to the overall quality of the underlying data has been tremendous. His work at retrosheet.org integrates the yearly data with the day-by-day data, -creating a reference source of startling depth. It is unlikely than -any individual has contributed as much to the field of baseball +creating a reference source of startling depth. It is unlikely than +any individual has contributed as much to the field of baseball research in the past five years as Ruane has. Sean Holtz helped with a major overhaul and redesign before the 2000 season. Keith Woolner was instrumental in helping turn a huge collection of stats into a relational database in the mid-1990s. -Clifford Otto & Ted Nye also helped provide guidance to the early +Clifford Otto & Ted Nye also helped provide guidance to the early versions. Lee Sinnis, John Northey & Erik Greenwood helped supply key -pieces of data. Many others have written in with corrections and +pieces of data. Many others have written in with corrections and suggestions that made each subsequent version even better than what -preceded it. +preceded it. The work of the SABR Baseball Records Committee, led by Lyle Spatz -has been invaluable. So has the work of Bill Carle and the SABR +has been invaluable. So has the work of Bill Carle and the SABR Biographical Committee. David Vincent, keeper of the Home Run Log and other bits of hard to find info, has always been helpful. The recent addition of colleges to player bios is the result of much research by members of SABR's Collegiate Baseball committee. Salary data was first supplied by Doug Pappas, who passed away during -the summer of 2004. He was the leading authority on many subjects, -most significantly the financial history of Major League Baseball. -We are grateful that he allowed us to include some of the data he -compiled. His work has been continued by the SABR Business of -Baseball committee. +the summer of 2004. He was the leading authority on many subjects, +most significantly the financial history of Major League Baseball. +We are grateful that he allowed us to include some of the data he +compiled. His work has been continued by the SABR Business of +Baseball committee. Thanks is also due to the staff at the National Baseball Library in Cooperstown who have been so helpful over the years, including -Tim Wiles, Jim Gates, Bruce Markusen, and the rest of the staff. +Tim Wiles, Jim Gates, Bruce Markusen, and the rest of the staff. A special debt of gratitude is owed to Dave Smith and the folks at Retrosheet. There is no other group working so hard to compile and @@ -268,7 +268,7 @@ a wonderful thing. This version of the database is available in Microsoft Access format, SQL files or in a generic, comma delimited format. Because this is a relational database, you will not be able to use the data in a -flat-database application. +flat-database application. Please note that this is not a stand alone application. It requires a database application or some other application designed specifically @@ -277,7 +277,7 @@ to interact with the database. If you are unable to import the data directly, you should download the database in the delimted text format. Then use the documentation in sections 2.1 through 2.22 of this document to import the data into -your database application. +your database application. ---------------------------------------------------------------------- 1.5 Revision History @@ -286,11 +286,11 @@ your database application. 1.0 December 1992 Database ported from dBase 1.1 May 1993 Becomes fully relational 1.2 July 1993 Corrections made to full database - 1.21 December 1993 1993 statistics added - 1.3 July 1994 Pre-1900 data added + 1.21 December 1993 1993 statistics added + 1.3 July 1994 Pre-1900 data added 1.31 February 1995 1994 Statistics added 1.32 August 1995 Statistics added for other leagues - 1.4 September 1995 Fielding Data added + 1.4 September 1995 Fielding Data added 1.41 November 1995 1995 statistics added 1.42 March 1996 HOF/All-Star tables added 1.5-MS October 1996 1st public release - MS Access format @@ -318,14 +318,14 @@ your database application. 2013 December 2013 Updated with 2013 season statistics 2014 December 2014 Updated with 2013 season statistics - + ------------------------------------------------------------------------------ 2.0 Data Tables The design follows these general principles. Each player is assigned a unique number (playerID). All of the information relating to that player -is tagged with his playerID. The playerIDs are linked to names and +is tagged with his playerID. The playerIDs are linked to names and birthdates in the MASTER table. The database is comprised of the following main tables: @@ -340,17 +340,17 @@ It is supplemented by these tables: AllStarFull - All-Star appearances HallofFame - Hall of Fame voting data Managers - managerial statistics - Teams - yearly stats and standings + Teams - yearly stats and standings BattingPost - post-season batting statistics PitchingPost - post-season pitching statistics TeamFranchises - franchise information - FieldingOF - outfield position data + FieldingOF - outfield position data FieldingPost- post-season fieldinf data ManagersHalf - split season data for managers TeamsHalf - split season data for teams Salaries - player salary data SeriesPost - post-season series information - AwardsManagers - awards won by managers + AwardsManagers - awards won by managers AwardsPlayers - awards won by players AwardsShareManagers - award voting for manager awards AwardsSharePlayers - award voting for player awards @@ -386,7 +386,7 @@ nameLast Player's last name nameGiven Player's given name (typically first and middle) weight Player's weight in pounds height Player's height in inches -bats Player's batting hand (left, right, or both) +bats Player's batting hand (left, right, or both) throws Player's throwing hand (left or right) debut Date that player made first major league appearance finalGame Date that player made first major league appearance (blank if still active) @@ -431,7 +431,7 @@ W Wins L Losses G Games GS Games Started -CG Complete Games +CG Complete Games SHO Shutouts SV Saves IPOuts Outs Pitched (innings pitched x 3) @@ -461,9 +461,9 @@ stint player's stint (order of appearances within a season) teamID Team lgID League Pos Position -G Games +G Games GS Games Started -InnOuts Time played in the field expressed as outs +InnOuts Time played in the field expressed as outs PO Putouts A Assists E Errors @@ -499,7 +499,7 @@ category Category in which candidate was honored needed_note Explanation of qualifiers for special elections ------------------------------------------------------------------------------ 2.7 Managers table - + playerID Player ID Number yearID Year teamID Team @@ -569,7 +569,7 @@ teamIDretro Team ID used by Retrosheet 2.9 BattingPost table yearID Year -round Level of playoffs +round Level of playoffs playerID Player ID code teamID Team lgID League @@ -596,7 +596,7 @@ GIDP Grounded into double plays playerID Player ID code yearID Year -round Level of playoffs +round Level of playoffs teamID Team lgID League W Wins @@ -604,7 +604,7 @@ L Losses G Games GS Games Started CG Complete Games -SHO Shutouts +SHO Shutouts SV Saves IPOuts Outs Pitched (innings pitched x 3) H Hits @@ -686,11 +686,11 @@ salary Salary 2.16 SeriesPost table yearID Year -round Level of playoffs +round Level of playoffs teamIDwinner Team ID of the team that won the series lgIDwinner League ID of the team that won the series teamIDloser Team ID of the team that lost the series -lgIDloser League ID of the team that lost the series +lgIDloser League ID of the team that lost the series wins Wins by team that won the series losses Losses by team that won the series ties Tie games @@ -743,11 +743,11 @@ playerID Player ID code yearID Year teamID Team lgID League -round Level of playoffs +round Level of playoffs Pos Position -G Games +G Games GS Games Started -InnOuts Time played in the field expressed as outs +InnOuts Time played in the field expressed as outs PO Putouts A Assists E Errors @@ -800,4 +800,3 @@ year year - \ No newline at end of file diff --git a/datasets/bikes/Readme.txt b/datasets/bikes/Readme.txt index 10c20ce..1a797a1 100644 --- a/datasets/bikes/Readme.txt +++ b/datasets/bikes/Readme.txt @@ -11,14 +11,14 @@ Rua Dr. Roberto Frias, 378 ========================================= -Background +Background ========================================= -Bike sharing systems are new generation of traditional bike rentals where whole process from membership, rental and return -back has become automatic. Through these systems, user is able to easily rent a bike from a particular position and return -back at another position. Currently, there are about over 500 bike-sharing programs around the world which is composed of -over 500 thousands bicycles. Today, there exists great interest in these systems due to their important role in traffic, -environmental and health issues. +Bike sharing systems are new generation of traditional bike rentals where whole process from membership, rental and return +back has become automatic. Through these systems, user is able to easily rent a bike from a particular position and return +back at another position. Currently, there are about over 500 bike-sharing programs around the world which is composed of +over 500 thousands bicycles. Today, there exists great interest in these systems due to their important role in traffic, +environmental and health issues. Apart from interesting real world applications of bike sharing systems, the characteristics of data being generated by these systems make them attractive for the research. Opposed to other transport services such as bus or subway, the duration @@ -30,21 +30,21 @@ events in the city could be detected via monitoring these data. Data Set ========================================= Bike-sharing rental process is highly correlated to the environmental and seasonal settings. For instance, weather conditions, -precipitation, day of week, season, hour of the day, etc. can affect the rental behaviors. The core data set is related to -the two-year historical log corresponding to years 2011 and 2012 from Capital Bikeshare system, Washington D.C., USA which is -publicly available in http://capitalbikeshare.com/system-data. We aggregated the data on two hourly and daily basis and then -extracted and added the corresponding weather and seasonal information. Weather information are extracted from http://www.freemeteo.com. +precipitation, day of week, season, hour of the day, etc. can affect the rental behaviors. The core data set is related to +the two-year historical log corresponding to years 2011 and 2012 from Capital Bikeshare system, Washington D.C., USA which is +publicly available in http://capitalbikeshare.com/system-data. We aggregated the data on two hourly and daily basis and then +extracted and added the corresponding weather and seasonal information. Weather information are extracted from http://www.freemeteo.com. ========================================= Associated tasks ========================================= - - Regression: + - Regression: Predication of bike rental count hourly or daily based on the environmental and seasonal settings. - - - Event and Anomaly Detection: + + - Event and Anomaly Detection: Count of rented bikes are also correlated to some events in the town which easily are traceable via search engines. - For instance, query like "2012-10-30 washington d.c." in Google returns related results to Hurricane Sandy. Some of the important events are + For instance, query like "2012-10-30 washington d.c." in Google returns related results to Hurricane Sandy. Some of the important events are identified in [1]. Therefore the data can be used for validation of anomaly or event detection algorithms as well. @@ -56,12 +56,12 @@ Files - hour.csv : bike sharing counts aggregated on hourly basis. Records: 17379 hours - day.csv - bike sharing counts aggregated on daily basis. Records: 731 days - + ========================================= Dataset characteristics -========================================= +========================================= Both hour.csv and day.csv have the following fields, except hr which is not available in day.csv - + - instant: record index - dteday : date - season : season (1:springer, 2:summer, 3:fall, 4:winter) @@ -71,7 +71,7 @@ Both hour.csv and day.csv have the following fields, except hr which is not avai - holiday : weather day is holiday or not (extracted from http://dchr.dc.gov/page/holiday-schedule) - weekday : day of the week - workingday : if day is neither weekend nor holiday is 1, otherwise is 0. - + weathersit : + + weathersit : - 1: Clear, Few clouds, Partly cloudy, Partly cloudy - 2: Mist + Cloudy, Mist + Broken clouds, Mist + Few clouds, Mist - 3: Light Snow, Light Rain + Thunderstorm + Scattered clouds, Light Rain + Scattered clouds @@ -83,7 +83,7 @@ Both hour.csv and day.csv have the following fields, except hr which is not avai - casual: count of casual users - registered: count of registered users - cnt: count of total rental bikes including both casual and registered - + ========================================= License ========================================= @@ -107,5 +107,5 @@ Use of this dataset in publications must be cited to the following publication: ========================================= Contact ========================================= - + For further information about this dataset please contact Hadi Fanaee-T (hadi.fanaee@fe.up.pt) diff --git a/datasets/biofilm.csv b/datasets/biofilm.csv index 738d728..b728566 100644 --- a/datasets/biofilm.csv +++ b/datasets/biofilm.csv @@ -94,4 +94,4 @@ experiment,isolate,ST,OD600,measurement,replicate,normalized_measurement 2,13,4,0.522,1.316,3,2.521072797 2,14,4,0.576,1.959,3,3.401041667 2,15,4,0.427,1.073,3,2.512880562 -2,ATCC_29212,30,0.688,1.122,3,1.630813953 \ No newline at end of file +2,ATCC_29212,30,0.688,1.122,3,1.630813953 diff --git a/datasets/mlb_2013-2016.csv b/datasets/mlb_2013-2016.csv index 689334e..aae2ecb 100644 --- a/datasets/mlb_2013-2016.csv +++ b/datasets/mlb_2013-2016.csv @@ -118,4 +118,4 @@ Season,Team,Team Salary,Team Salary (in millions),League,Wins,Losses,Winning %,A 2013,Tampa Bay Rays,57030272,57,AL,92,71,0.564,5538,700,1421,296,23,165,670,589,1171,73,38,0.257,0.329,0.408,0.737,3.74,42,60,1464,1315,646,608,153,482,1310,0.24,1.23,13176,6044,4392,1593,59,147,0.783,69,0.99,0.708 2013,Texas Rangers,127197575,127.2,AL,91,72,0.558,5585,730,1465,262,23,176,691,462,1067,149,46,0.262,0.323,0.412,0.735,3.62,46,57,1463.1,1370,636,589,157,498,1309,0.248,1.28,13170,6025,4390,1549,86,146,0.682,68,0.986,0.695 2013,Toronto Blue Jays,118244039,118.2,AL,74,88,0.457,5537,712,1398,273,24,185,669,510,1123,112,41,0.252,0.318,0.411,0.729,4.25,39,58,1452,1451,756,685,195,500,1208,0.259,1.34,13068,6072,4356,1605,111,145,0.75,54,0.982,0.691 -2013,Washington Nationals,112431770,112.4,NL,86,76,0.531,5436,656,1365,259,27,161,621,464,1192,88,28,0.251,0.313,0.398,0.71,3.59,47,68,1445.2,1367,626,576,142,405,1236,0.249,1.23,13011,5993,4337,1549,107,146,0.826,43,0.982,0.691 \ No newline at end of file +2013,Washington Nationals,112431770,112.4,NL,86,76,0.531,5436,656,1365,259,27,161,621,464,1192,88,28,0.251,0.313,0.398,0.71,3.59,47,68,1445.2,1367,626,576,142,405,1236,0.249,1.23,13011,5993,4337,1549,107,146,0.826,43,0.982,0.691 diff --git a/datasets/ship-damage.txt b/datasets/ship-damage.txt index 8635d49..4ebf826 100644 --- a/datasets/ship-damage.txt +++ b/datasets/ship-damage.txt @@ -32,4 +32,4 @@ type,yr_construction,period_op,months,n_damages 5,2,2,437,7 5,3,1,1157,5 5,3,2,2161,12 -5,4,2,542,1 \ No newline at end of file +5,4,2,542,1 diff --git a/models/__init__.py b/models/__init__.py index 3017a80..2dc0ac9 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -115,4 +115,4 @@ def plot_elbo(self): plt.plot(-self.advi_hist) plt.ylabel('ELBO') plt.xlabel('iteration') - sns.despine() \ No newline at end of file + sns.despine() diff --git a/models/feedforward.py b/models/feedforward.py index 58d3e93..dbb4c9f 100644 --- a/models/feedforward.py +++ b/models/feedforward.py @@ -6,7 +6,7 @@ class ForestCoverModel(BayesianModel): - + def __init__(self, n_hidden): super(ForestCoverModel, self).__init__() self.n_hidden = n_hidden @@ -14,25 +14,25 @@ def __init__(self, n_hidden): def create_model(self, X=None, y=None): if X: num_samples, self.num_pred = X.shape - + if y: num_samples, self.num_out = Y.shape model_input = theano.shared(np.zeros(shape=(1, self.num_pred))) model_output = theano.shared(np.zeros(shape=(1,self.num_out))) - + self.shared_vars = { 'model_input': model_input, 'model_output': model_output } - + with pm.Model() as model: # Define weights - weights_1 = pm.Normal('w_1', mu=0, sd=1, + weights_1 = pm.Normal('w_1', mu=0, sd=1, shape=(self.num_pred, self.n_hidden)) weights_2 = pm.Normal('w_2', mu=0, sd=1, shape=(self.n_hidden, self.n_hidden)) - weights_out = pm.Normal('w_out', mu=0, sd=1, + weights_out = pm.Normal('w_out', mu=0, sd=1, shape=(self.n_hidden, self.num_outs)) # Define activations @@ -41,29 +41,27 @@ def create_model(self, X=None, y=None): acts_out = tt.nnet.softmax(tt.dot(acts_2, weights_out)) # noqa # Define likelihood - out = pm.Multinomial('likelihood', n=1, p=acts_out, + out = pm.Multinomial('likelihood', n=1, p=acts_out, observed=model_output) - + return model - - + + def fit(self, X, y, n=200000, batch_size=10): """ Train the Bayesian NN model. """ num_samples, self.num_pred = X.shape _, self.num_out = y.shape - + if self.cached_model is None: self.cached_model = self.create_model() - + with self.cached_model: minibatches = { self.shared_vars['model_input']: pm.Minibatch(X, batch_size=batch_size), self.shared_vars['model_output']: pm.Minibatch(y, batch_size=batch_size), } self._inference(minibatches, n) - + return self - - diff --git a/test_gpu.py b/test_gpu.py index ce2ca4b..d91d665 100644 --- a/test_gpu.py +++ b/test_gpu.py @@ -21,4 +21,3 @@ print('Used the cpu') else: print('Used the gpu') -