Skip to content
Snippets Groups Projects
Commit dc93ef02 authored by Nikolai's avatar Nikolai
Browse files

Merge remote-tracking branch 'origin/master'

parents a396d67b 8dc10a7e
No related branches found
No related tags found
No related merge requests found
...@@ -108,7 +108,7 @@ class ClassificationProject(object): ...@@ -108,7 +108,7 @@ class ClassificationProject(object):
:param layers: number of layers in the neural network :param layers: number of layers in the neural network
:param nodes: number of nodes in each layer :param nodes: list number of nodes in each layer. If only a single number is given, use this number for every layer
:param dropout: dropout fraction after each hidden layer. Set to None for no Dropout :param dropout: dropout fraction after each hidden layer. Set to None for no Dropout
...@@ -236,6 +236,12 @@ class ClassificationProject(object): ...@@ -236,6 +236,12 @@ class ClassificationProject(object):
self.identifiers = identifiers self.identifiers = identifiers
self.layers = layers self.layers = layers
self.nodes = nodes self.nodes = nodes
if not isinstance(self.nodes, list):
self.nodes = [self.nodes for i in range(self.layers)]
if len(self.nodes) != self.layers:
self.layers = len(self.nodes)
logger.warning("Number of layers not equal to the given nodes "
"per layer - adjusted to " + str(self.layers))
self.dropout = dropout self.dropout = dropout
self.batch_size = batch_size self.batch_size = batch_size
self.validation_split = validation_split self.validation_split = validation_split
...@@ -583,10 +589,10 @@ class ClassificationProject(object): ...@@ -583,10 +589,10 @@ class ClassificationProject(object):
self._model = Sequential() self._model = Sequential()
# first hidden layer # first hidden layer
self._model.add(Dense(self.nodes, input_dim=len(self.fields), activation=self.activation_function)) self._model.add(Dense(self.nodes[0], input_dim=len(self.fields), activation=self.activation_function))
# the other hidden layers # the other hidden layers
for layer_number in range(self.layers-1): for node_count, layer_number in zip(self.nodes[1:], range(self.layers-1)):
self._model.add(Dense(self.nodes, activation=self.activation_function)) self._model.add(Dense(node_count, activation=self.activation_function))
if self.dropout is not None: if self.dropout is not None:
self._model.add(Dropout(rate=self.dropout)) self._model.add(Dropout(rate=self.dropout))
# last layer is one neuron (binary classification) # last layer is one neuron (binary classification)
......
...@@ -6,6 +6,7 @@ import numpy as np ...@@ -6,6 +6,7 @@ import numpy as np
import keras.backend as K import keras.backend as K
from sklearn.preprocessing import RobustScaler from sklearn.preprocessing import RobustScaler
from sklearn.preprocessing.data import _handle_zeros_in_scale
from meme import cache from meme import cache
...@@ -140,5 +141,6 @@ class WeightedRobustScaler(RobustScaler): ...@@ -140,5 +141,6 @@ class WeightedRobustScaler(RobustScaler):
wqs = np.array([weighted_quantile(X[:,i], [0.25, 0.5, 0.75], sample_weight=weights) for i in range(X.shape[1])]) wqs = np.array([weighted_quantile(X[:,i], [0.25, 0.5, 0.75], sample_weight=weights) for i in range(X.shape[1])])
self.center_ = wqs[:,1] self.center_ = wqs[:,1]
self.scale_ = wqs[:,2]-wqs[:,0] self.scale_ = wqs[:,2]-wqs[:,0]
self.scale_ = _handle_zeros_in_scale(self.scale_, copy=False)
return self return self
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment