Skip to content

Instantly share code, notes, and snippets.

@javaeeeee
javaeeeee / Compile Tensorflow Model
Created July 5, 2021 20:46
Compile Tensorflow Model
model.compile(Adam(learning_rate=1e-4),
loss='binary_crossentropy',
metrics=['binary_accuracy'])
@javaeeeee
javaeeeee / Tensorflow Binary Classification Model
Created July 5, 2021 20:44
Tensorflow Binary Classification Model
model = Sequential()
model.add(normalizer)
model.add(Dense(5, input_shape=(X_train.shape[1],),
activation='relu', kernel_initializer='he_normal'))
model.add(Dropout(0.2))
model.add(Dense(5, activation="relu",
kernel_initializer='he_normal'))
model.add(Dropout(0.2))
model.add(Dense(1, activation="sigmoid",
kernel_initializer="glorot_normal"))
@javaeeeee
javaeeeee / Tensorflow Preprocessing Normalizer
Created July 5, 2021 20:43
Tensorflow Preprocessing Normalizer
normalizer = preprocessing.Normalization(axis=-1)
normalizer.adapt(np.array(X_train))
normalizer.mean.numpy()
@javaeeeee
javaeeeee / HelloControllerTest.java
Created February 25, 2017 21:05
A Spring MVC REST controller test for a Spring Boot application
package com.javaeeeee.controllers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
@javaeeeee
javaeeeee / HelloControllerTest.java
Created February 25, 2017 20:34
A test for a Spring MVC REST Controller
package com.javaeeeee.springrest.controllers;
import org.junit.Test;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
@javaeeeee
javaeeeee / HelloController.java
Created February 25, 2017 20:32
An example Spring MVC REST controller
package com.javaeeeee.springrest.controllers;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/hello")
public String getGreeting() {
@javaeeeee
javaeeeee / dispatcher-servlet.xml
Created February 25, 2017 20:30
An example of Spring XML configuration file
<?xml version="1.0" encoding="windows-1252"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
@javaeeeee
javaeeeee / web.xml
Created February 25, 2017 20:29
An example of web.xml file with configured Spring DispatcherServlet
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
@javaeeeee
javaeeeee / tomcat-users.xml
Created February 25, 2017 20:26
A Tomcat configuration file
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd">
<role rolename="manager-gui"/>
<user password="1" roles="manager-gui,manager-script,admin" username="admin"/>
</tomcat-users>
@javaeeeee
javaeeeee / pom.xml
Created February 25, 2017 20:22
A pom file for a simple Spring MVC application
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javaeeeee</groupId>
<artifactId>SpringREST</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>SpringREST Maven Webapp</name>
<url>http://maven.apache.org</url>