def build_model(self, n_features, n_classes): """Create the computational graph of the model. :param n_features: Number of features. :param n_classes: number of classes. :return: self """ self._create_placeholders(n_features, n_classes) self._create_layers(n_classes) self.cost = self.loss.compile(self.mod_y, self.input_labels) self.train_step = self.trainer.compile(self.cost) self.accuracy = Evaluation.accuracy(self.mod_y, self.input_labels)
def build_model(self, n_features, n_classes): """Create the computational graph. This graph is intented to be created for finetuning, i.e. after unsupervised pretraining. :param n_features: Number of features. :param n_classes: number of classes. :return: self """ self._create_placeholders(n_features, n_classes) self._create_variables(n_features) self.global_step = tf.Variable(0, dtype=tf.int32) self.trainer = Trainer( self.opt, global_step=self.global_step, decay_step=self.decay_step, decay_rate=self.decay_rate, learning_rate=self.learning_rate, momentum=self.momentum) self.next_train = self._create_encoding_layers() self.mod_y, _, _ = Layers.linear(self.next_train, n_classes) self.layer_nodes.append(self.mod_y) self.cost = self.loss.compile(self.mod_y, self.input_labels) self.train_step = self.trainer.compile(self.cost, self.global_step) self.accuracy = Evaluation.accuracy(self.mod_y, self.input_labels) self.precision = Evaluation.precision(self.mod_y, self.input_labels) self.recall = Evaluation.recall(self.mod_y, self.input_labels)
def build_model(self, n_features, n_classes): """Create the computational graph. :param n_features: number of features :param n_classes: number of classes :return: self """ self._create_placeholders(n_features, n_classes) self._create_variables(n_features, n_classes) self.mod_y = tf.nn.softmax( tf.add(tf.matmul(self.input_data, self.W_), self.b_)) self.cost = self.loss.compile(self.mod_y, self.input_labels) self.train_step = tf.train.GradientDescentOptimizer( self.learning_rate).minimize(self.cost) self.accuracy = Evaluation.accuracy(self.mod_y, self.input_labels)
def build_model(self, n_features, n_classes): """Create the computational graph. This graph is intented to be created for finetuning, i.e. after unsupervised pretraining. :param n_features: Number of features. :param n_classes: number of classes. :return: self """ self._create_placeholders(n_features, n_classes) self._create_variables(n_features) next_train = self._create_encoding_layers() self.mod_y, _, _ = Layers.linear(next_train, n_classes) self.layer_nodes.append(self.mod_y) self.cost = self.loss.compile(self.mod_y, self.input_labels) self.train_step = self.trainer.compile(self.cost) self.accuracy = Evaluation.accuracy(self.mod_y, self.input_labels)