Skip to content

Instantly share code, notes, and snippets.

package com.johnny12150.internet;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
@johnny12150
johnny12150 / dcgan_cartoon.py
Last active July 13, 2019 07:26
G: 1300萬 D: 190萬
def build_generator(self):
noise_input = Input(shape=(self.noise_dim,))
x = Dense(128 * 4 * 4)(noise_input)
x = LeakyReLU()(x)
x = Reshape((4, 4, 128))(x)
x = UpSampling2D()(x)
x = Conv2D(1024, kernel_size=4, padding="same")(x)
x = BatchNormalization(momentum=0.8)(x)
@johnny12150
johnny12150 / dl.py
Created October 14, 2019 07:32
fetch uva PDFs
from urllib.request import urlretrieve
def main(problem_num):
dl_str = "https://uva.onlinejudge.org/external/"+ str(int(problem_num/100)) +"/"+ str(problem_num) +".pdf"
urlretrieve(dl_str, "./PDF/uva_" + str(problem_num) + ".pdf")
print(dl_str)
files = [100, 488, 913, 11150, 11877, 10035, 10055, 10071, 10550, 10673, 10696, 10783, 10812, 10929, 11172, 11332, 11479, 11689, 11743, 11764, 12019, 12149, 12459, 12468, 13187]
@johnny12150
johnny12150 / dblp_v11.json
Last active November 19, 2019 03:07
smaple of v11 dblp
{
"id": "1000018889",
"title": "Remote Policy Enforcement for Trusted Application Execution in Mobile Environments",
"authors": [
{
"name": "Fabio Martinelli",
"id": "2107438709",
"org": "Istituto di Informatica e Telematica, Consiglio Nazionale delle Ricerche, Pisa, Italy#TAB#"
},
{
classifier = [1, 3, 5, 20, 100, 200]
# test
trpf3 = np.zeros((tepn, fn))
trnf3 = np.zeros((tenn, fn))
for c in range(fn):
trpf3[:, c] = fe(testface, ftable, c)
trnf3[:, c] = fe(testnonface, ftable, c)
for k in classifier:
# training error
trps = np.zeros((trpn, 1))
maxprofit=-10000
profit = np.zeros((len(tradeday),1))
for n in range(10,100,10):
for m in range(n,110,10):
for i in range(len(tradeday)):
date = tradeday[i]
idx = np.nonzero(TAIEX[:,0]//10000==date)[0]
idx.sort()
p1 = TAIEX[idx[0],2]
idx2 = np.nonzero(TAIEX[idx,4]<=p1-n)[0] #停損情況
#include <iostream>
#include <unistd.h>
#include <termios.h>
char _getch(){
char buf=0;
struct termios old={0};
fflush(stdout);
if(tcgetattr(0, &old)<0)
perror("tcsetattr()");
old.c_lflag&=~ICANON;
refs = [] # 所有被引用過的
for i, ref in dblp.dropna(subset=['references']).references.iteritems():
refs.extend(ast.literal_eval(ref))
# 取獨一無二
refs = list(set(refs))
refs = list(map(float, refs))
# 保留在reference裡的
dblp_all = dblp_all[dblp_all['id'].isin(refs)]
# 找2011前的
# coding: utf-8
# 可參考 https://keras.io/examples/variational_autoencoder/
# TODO: import你會用到的套件
# TODO: 讀圖片檔(會用到RGB、resize、normalize)
def load_data():
return
def build_encoder():
from keras.datasets import mnist
import numpy as np
import matplotlib.pyplot as plt
from keras.models import Model, Input
from keras.layers.core import Dense
from keras.layers import Input, Conv2D, MaxPooling2D, UpSampling2D
(x_train, _), (x_test, _) = mnist.load_data()
x_train = x_train.astype('float32')/ 255.
x_test = x_test.astype('float32')/ 255.