Skip to content

Commit

Permalink
Reorganized for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
wzwietering committed Feb 27, 2020
1 parent 780598d commit ab7b00a
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 25 deletions.
Empty file added model_builder/__init__.py
Empty file.
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from analyzers.analyzer import Analyzer
from layers.reshape_layer import ReshapeLayer
from model_builder.analyzers.analyzer import Analyzer
from model_builder.layers.reshape_layer import ReshapeLayer

class CRNNAnalyzer(Analyzer):
def analyze(self, model):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from analyzers.analyzer import Analyzer
from layers.rnn_layer import RNNLayer
from model_builder.analyzers.analyzer import Analyzer
from model_builder.layers.rnn_layer import RNNLayer

# If the final layer of a model is a RNNLayer, it should not return its
# sequences. This analyzer ensures this.
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Dropout, AveragePooling2D
from layers.layer import Layer
from model_builder.layers.layer import Layer

class Conv2DLayer(Layer):
def __init__(self,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tensorflow.keras.layers import Dense, Dropout
from layers.layer import Layer
from model_builder.layers.layer import Layer

class DenseLayer(Layer):
def __init__(self, parent, units=None, dropout=None):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tensorflow.keras.layers import GaussianNoise
from layers.layer import Layer
from model_builder.layers.layer import Layer

class GaussianNoiseLayer(Layer):
def __init__(self, parent, stddev):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tensorflow.keras.layers import Input
from layers.layer import Layer
from model_builder.layers.layer import Layer

class InputLayer(Layer):
def __init__(self, parent, shape):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tensorflow.keras.layers import Reshape
from layers.layer import Layer
from model_builder.layers.layer import Layer

# Reshape automatically determines how to reshape. Reshaping is done by
# multiplying the original dimensions from left to right with eachother.
Expand Down
2 changes: 1 addition & 1 deletion layers/rnn_layer.py → model_builder/layers/rnn_layer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tensorflow.keras.layers import SimpleRNN, LSTM, GRU, Bidirectional
from layers.layer import Layer
from model_builder.layers.layer import Layer

class RNNLayer(Layer):
def __init__(self,
Expand Down
2 changes: 1 addition & 1 deletion model.py → model_builder/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from tensorflow.keras.layers import Activation, Dense
import tensorflow.keras.models
from layers.input_layer import InputLayer
from model_builder.layers.input_layer import InputLayer

class Model():
def __init__(self, loss, optimizer, activation, metrics=None):
Expand Down
4 changes: 2 additions & 2 deletions model_analyzer.py → model_builder/model_analyzer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from analyzers.rnn_return_sequences import RNNReturnSequences
from analyzers.crnn_analyzer import CRNNAnalyzer
from model_builder.analyzers.rnn_return_sequences import RNNReturnSequences
from model_builder.analyzers.crnn_analyzer import CRNNAnalyzer

class ModelAnalyzer():
def __init__(self):
Expand Down
4 changes: 2 additions & 2 deletions model_builder.py → model_builder/model_builder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from model_parser import Parser
from model_analyzer import ModelAnalyzer
from model_builder.model_parser import Parser
from model_builder.model_analyzer import ModelAnalyzer

class ModelBuilder():
def __init__(self):
Expand Down
12 changes: 6 additions & 6 deletions model_parser.py → model_builder/model_parser.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from model import Model
from layers.conv2d_layer import Conv2DLayer
from layers.dense_layer import DenseLayer
from layers.rnn_layer import RNNLayer
from layers.reshape_layer import ReshapeLayer
from layers.gaussian_noise_layer import GaussianNoiseLayer
from model_builder.model import Model
from model_builder.layers.conv2d_layer import Conv2DLayer
from model_builder.layers.dense_layer import DenseLayer
from model_builder.layers.rnn_layer import RNNLayer
from model_builder.layers.reshape_layer import ReshapeLayer
from model_builder.layers.gaussian_noise_layer import GaussianNoiseLayer

class Parser():
def parse_config(self, config):
Expand Down
2 changes: 1 addition & 1 deletion model_serializer.py → model_builder/model_serializer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from model import Model
from model_builder.model import Model

class ModelSerializer():
def serialize(self, model):
Expand Down
25 changes: 25 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import setuptools

with open("README.md", "r") as f:
readme = f.read()

setuptools.setup(
name='model_builder',
version='0.1.0',
author="Wilmer Zwietering",
author_email="[email protected]",
description="Easily build Keras models from code or from a configuration file",
long_description=readme,
long_description_content_type="text/markdown",
url="https://github.com/wzwietering/model_builder",
packages=setuptools.find_packages(),
classifiers=[
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Topic :: Utilities",
],
install_requires=["tensorflow"],
python_requires='>=3.6',
)
6 changes: 3 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import model_builder
import model_parser
import model_serializer
from model_builder import model_builder
from model_builder import model_parser
from model_builder import model_serializer

def test_config(filename, input_shape, output_shape=10):
with open(filename, "r") as f:
Expand Down

0 comments on commit ab7b00a

Please sign in to comment.