Skip to content

Instantly share code, notes, and snippets.

# 匯入各種第三方函式庫(Library)
library(clusterProfiler)
library(dplyr)
library(enrichplot)
library(org.Hs.eg.db)
library(msigdbr)
library(DOSE)
library(rlang)
library(export)
---------------------------------------------------------------
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
dic = {}
for i, num in enumerate(nums):
if target - num in dic:
return([dic[target - num], i])
dic[num] = i
return([])
@MortisHuang
MortisHuang / tf2_test.py
Created December 11, 2019 06:19
Test TensorFlow 2.0
from __future__ import absolute_import, division, print_function, unicode_literals
# TensorFlow and tf.keras
import tensorflow as tf
from tensorflow import keras
# import matplotlib.pyplot as plt
print(tf.__version__)
@MortisHuang
MortisHuang / GPU_Detection.py
Created December 11, 2019 06:17
GPU Device Detection
#%% GPU Device Detection
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
@MortisHuang
MortisHuang / tSNE_example_2.py
Created November 10, 2019 09:44
tSNE_example_2
from sklearn import manifold, datasets
digits = datasets.load_digits(n_class=6)
X, y = digits.data, digits.target
X_tsne = manifold.TSNE(n_components=2, init='random', random_state=5, verbose=1).fit_transform(X)
@MortisHuang
MortisHuang / tSNE_example_1.py
Created November 10, 2019 09:02
t-SNE Example 1
import numpy as np
import matplotlib.pyplot as plt
from sklearn import manifold, datasets
#Prepare the data
digits = datasets.load_digits(n_class=6)
X, y = digits.data, digits.target
n_samples, n_features = X.shape
n = 20
img = np.zeros((10 * n, 10 * n))
for i in range(n):
@MortisHuang
MortisHuang / upload_new_post_wordpress.py
Created September 3, 2019 08:33
upload_new_post_wordpress
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.users import GetUserInfo
from wordpress_xmlrpc.methods.posts import GetPosts, NewPost
#網站登入資訊
id="你的後台登入帳號"
password="你的後台登入密碼"
#網站網址,請把example.com替換成你的網址,並且先試著連上該網址,應該會出現「XML-RPC server accepts POST requests only.」才對。
url="https://example.com/xmlrpc.php"
width=28
height=28
channels=1
noise_plot = np.random.normal(0, 1, (16, 10))
shape = (width, height, channels)
optimizer = Adam(lr=0.0002, beta_1=0.5, decay=8e-8)
G = generator()
def stacked_generator_discriminator(G,D):
D.trainable = False
model = Sequential()
model.add(G)
model.add(D)
return model
def discriminator():
""" Declare discriminator """
model = Sequential()
model.add(Flatten(input_shape=shape))
model.add(Dense((width * height * channels), input_shape=shape))
model.add(LeakyReLU(alpha=0.2))
model.add(Dense(int((width * height * channels)/2)))
model.add(LeakyReLU(alpha=0.2))
model.add(Dense(1, activation='sigmoid'))