This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras import Sequential | |
from keras.layers import Conv2D, AveragePooling2D, Flatten, Dense | |
# http://yann.lecun.com/exdb/publis/pdf/lecun-01a.pdf | |
def create_lenet_5_model(input_shape=(32, 32, 1), output=10): | |
model = Sequential() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.models import Sequential | |
from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense | |
def create_alexnet_model(): | |
model = Sequential() | |
model.add(Conv2D(filters=48, input_shape=(224, 224, 3), kernel_size=(11, 11), strides=(4, 4), | |
activation='relu')) | |
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lenet5 import create_lenet_5_model | |
from keras.datasets import mnist | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# Fase di input | |
(x_train, y_train), (x_test, y_test) = mnist.load_data() | |
x_train = x_train.reshape(x_train.shape[0], 28, 28, 1) | |
x_test = x_test.reshape(x_test.shape[0], 28, 28, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import data | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
pd.set_option('display.max_columns', None) | |
italy = data._regions | |
italy.data = pd.to_datetime(italy.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
_provinces = pd.read_csv('./data/dati-province/dpc-covid19-ita-province.csv') | |
_regions = pd.read_csv('./data/dati-regioni/dpc-covid19-ita-regioni.csv') | |
def region(name: str = False): | |
if(name): | |
return _regions[_regions.denominazione_regione == name] | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseActivity: AppCompatActivity() { | |
private lateinit var logoutReceiver: BroadcastReceiver | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
logoutReceiver = LogoutReceiver() | |
registerReceiver(logoutReceiver, IntentFilter("ACTION_LOGOUT")) | |
} | |
override fun onStart() { | |
super.onStart() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface AnalyticsDelegate { | |
fun registerAnalytics(lifecycle: Lifecycle) | |
} | |
class AnalyticsDelegateImpl: AnalyticsDelegate, DefaultLifecycleObserver { | |
override fun registerAnalytics(lifecycle: Lifecycle) { | |
lifecycle.addObserver(this) | |
} | |
override fun onStart(owner: LifecycleOwner) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyActivity: | |
AppCompatActivity(), | |
AnalyticsDelegate by AnalyticsDelegateImpl(), | |
LogoutDelegate by LogoutDelegateImpl() | |
{ | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
registerAnalytics(lifecycle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface LogoutDelegate { | |
fun registerLogout(activity: AppCompatActivity) | |
} | |
class LogoutDelegateImpl: LogoutDelegate, DefaultLifecycleObserver { | |
private lateinit var activity: AppCompatActivity | |
override fun registerLogout(activity: AppCompatActivity) { | |
this.activity = activity | |
this.activity.lifecycle.addObserver(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun client(): OkHttpClient { | |
return OkHttpClient.Builder() | |
.certificatePinner( | |
CertificatePinner.Builder() | |
.add("*.github.com", "sha256/azE5Ew0LGsMgkYqiDpYay0olLAS8cxxNGUZ8OJU756k=") | |
.build() | |
) | |
.build() | |
} |
OlderNewer