Trial 1: Fashion MNIST dengan CNN

Setelah bergabung dengan group WA INAPR, group nya orang Indonesia yang tertarik bidang pattern recognition, saya menemukan hal-hal baru. Salah satunya adalah dataset Fashion MNIST dari Zalando, sebuah perusahaan fashion dari Jerman. Ketika ikut serta ICCV 2017 di Venice bulan lalu, saya juga hadir di workshop “Computer Vision for Fashion” yang diselenggarakan oleh Zalando ini. Tau Zalando ini ga sengaja juga, pergi ke booth mereka karena pengen kaos gratis. Maklum mahasiswa 😀

Sedikit informasi, Fashion MNIST ini karakteristiknya sama dengan MNIST dataset yang luar biasa terkenal. Orang yang baru belajar pattern recognition dan computer vision pasti pakai dataset ini ketika pertama kali simulasi. Jadi saya skip aja penjelasan panjangnya.

Berikut simulasi sederhana Fashion MNIST dengan CNN menggunaka Keras backend Tensor Flow.

  1. Load data Fashion MNIST
    link untuk mengunduh data:
    http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-images-idx3-ubyte.gz
    http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-labels-idx1-ubyte.gz
    http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-images-idx3-ubyte.gz
    http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-labels-idx1-ubyte.Setelah didownload, simpan dataset di folder data (untuk kasus saya)

    import gzip
    import idx2numpy
    
    def load_data():
    with gzip.open('./data/train-images-idx3-ubyte.gz', 'rb') as f:
    x_train = idx2numpy.convert_from_string(f.read())
    
    with gzip.open('./data/train-labels-idx1-ubyte.gz', 'rb') as f:
    y_train = idx2numpy.convert_from_string(f.read())
    
    with gzip.open('./data/t10k-images-idx3-ubyte.gz', 'rb') as f:
    x_test = idx2numpy.convert_from_string(f.read())
    
    with gzip.open('./data/t10k-labels-idx1-ubyte.gz', 'rb') as f:
    y_test = idx2numpy.convert_from_string(f.read())
    
    return (x_train, y_train), (x_test, y_test)
    
  2. Membangun architecture
# Load Data
(x_train, y_train), (x_test, y_test) = load_data()
# Input keras library
import keras
import numpy
from matplotlib import pyplot
from keras.models import Sequential
from keras.layers import Dense, Flatten, Dropout
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K

# parameters
batch_size = 128
num_classes = 10
epochs = 12

# input image dimensions
img_rows, img_cols = 28, 28

# Backend options
if K.image_data_format() == 'channels_first':
x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)
x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)
input_shape = (1, img_rows, img_cols)
else:
x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)
x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)
input_shape = (img_rows, img_cols, 1)

# Data normalization
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
x_train /=255
x_test /=255

# Print input samples
print('x_train shape:', x_train.shape)
print(x_train.shape[0], 'train samples')
print(x_test.shape[0], 'test samples')

# convert class vectors to binary class matricess
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)

# build simple CNN model
model = Sequential()
model.add(Conv2D(32, kernel_size=(3,3), activation='relu', input_shape=input_shape))
model.add(Conv2D(64, (3,3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))
model.summary()

model.compile(loss=keras.losses.categorical_crossentropy, optimizer=keras.optimizers.Adadelta(), metrics=['accuracy'])

model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs, verbose=1, validation_data=(x_test, y_test))

score = model.evaluate(x_test, y_test, verbose=0)

print('Test loss:', score[0])
print('Test accuracy:', score[1])

Hasil simulasi di atas
(‘Test loss:’, 0.23328696813583374)
(‘Test accuracy:’, 0.91510000000000002)

That’s it! Mudah kan? Selamat mencoba. Next saya coba pakai sequence model, RNN!

 

Advertisements

Starbase: get funded by issuing and selling tokens

Important information about Starbase.

What is Starbase?
The platform name; Starbase is both an open and closed source project. Starbase.Inc
will do technical consulting by providing a crowdfunding/sourcing platform which
enables you to issue conditional tokens from templates.

Starbase’s mission is to make it easy for everyone to start or support projects which
aim to create new services and products.
Starbase provides a crowdfunding and crowdsourcing/recruiting platform which gives
long-term incentive sharing mechanism on the “Internet of Value”.

STAR:
Currency symbol of Starbase token.

Token:
Token is a frequently used term in the blockchain industry for data which has some
value.

Core team:
People who are going to provide or who are currently providing some service or
product. They can be Global and innovative non-blockchain based projects, Startups, New business planners in big companies, Artists/Athletes/Talents, Event organizer.

Supporter:
Supporters are those who want to support projects by purchasing core team’s tokens
or by working on core team’s projects. They may be Blockchain engineers, designers, Non-blockchain Engineers, designers, Blockchain Marketers, Non-Blockchain Marketers, etc.

starbase

Beli Handphone di Korea

Kali ini gw mau share tentang pengalaman beli hape + kontrak di Korea. Sebenarnya ini bukan kali pertama beli hape di korea. Bulan Nopember 2013 gw beli iPhone 5s dengan kontrak 2 tahun. Saat itu hape iPhones 5s harganya 680K won. Dapat diskon sekitar 200K won karena kontrak 2 tahun. 3 bulan di awal bayar sekitar 100K untuk pake 5GB (kalau ga salah ingat). Saat itu visa yang dipake adalah E7, jadi pihak Olleh (gw pake KT Olleh tanpa alasan kuat, cuman ngeliat teman-teman sekitaran pake Olleh. FYI, 3 provider besar di Korea adalah SK Telecom, KT Olleh, dan LG U+). Anyway, setelah 3 tahun memakai iPhone 5S dengan performa yang memuaskan, akhirnya gw memutuskan untuk ganti hape dengan alasan baterainya sudah bermasalah alias cepat habis. Namun, kontrak hape 2 tahun tidak memungkinkan dengan status sebagai mahasiswa (visa D-2). Sedangkan beli hape yang gw pengen harganya cukup mahal. iPhone 6s atau iPhone SE ga affordable buat kantong. Akhirnya gw putuskan untuk memilih Samsung atau LG. Hape tipe-tipe Xiomi, Oneplus, Zenfone(?) susah didapatkan di Korea. Kudu impor dari Indonesia.

Dengan niat ga mau ganti provider karena sudah pakai Olleh selama 3 tahun dan punya Egg (portable AP) yang belum tau cara stop nya, akhirnya gw melakukan kunjungan ke Olleh store. Hasilnya adalah dengan visa D2 gw bisa kontrak 2 tahun tetapi harus membayar harga hape di depan. Setelah melakukan investigasi selama 4 hari (thanks to my wife yang udah support dan mendengarkan keluhan suami yang ga kunjung selesai selama 4 hari hanya untuk sebuah hape) dan survey web Olleh, LG, baca review, nonton review di youtube, akhirnya gw memutuskan hape Samsung Galaxy A5 2016. Why? Harganya terjangkau, middle range handphone, tapi designnya kayak high-end device. Kombinasi yang bagus. Tapi kalau pun ga pilih A5, gw tertarik dengan J7 kayak punya istri.

Di Indonesia harga baru hape A5 adalah 4.7juta. Di Olleh website harganya 429K won. Lumayan. Nguras budget juga kalau mesti beli cash. Tapi dengan sistem kontrak 2 tahun, gw dapat diskon 227K untuk langganan paket 54K per bulan (6GB LTE data, unlimited voice + sms). Bayar hapenya 168K won. Wow pisan. Good deal nih gw pikir. Pas kunjungan ke Olleh store yang ada di kampus, mbak nya bilang kalau gw kudu bayar 202K. Mikir juga kan. Setengah harga, tapi gw mau nya 168K. Dengan niat nyari diskon, gw pun pergi ke toko lain yang kata google penjaga tokonya bisa Bahasa Inggris. Alhamdulillah, yang punya orangnya baik banget. Gw dikasih 168K seperti yang tertulis di Olleh web. Pas datanya diproses, gw dapat diskon lagi 36K won karena punya Olleh membership points. Untungnya setia pakai Olleh. Wow. Alhamdulillah pisan. Jadi total yang dibayar hanya 132K untuk device, casing transparent, anti gores, dan Xiomi powerbank 5000mAh. Yeayyy… Ini hape Android gw yang pertama. So far so good, GUI nya masih smooth dan ga ribet-ribet banget. Moga-moga awet dan berkah pake hape ini. Aamiin.

NB: foto hape dan review lain insyaAllah menyusul

Website Gratis

Pembuatan website untuk sebuah event di zaman komunikasi dan teknologi super canggih tidak memerlukan kemampuan programming yang luar biasa. Newbie seperti gue pun bisa membuatnya. Kali ini pilihan gue menggunakan wix.com sepertinya pilihan yang paling tepat. Ga seperti wordpress, wix menggunakan template yang sudah ada dan tinggal drag & drop aja. Dengan memilih template yang ada, customization yang gue inginkan bisa jadi dalam 1 jam. Yang perlu lebih dipertimbangkan adalah pembuatan gambar (images) agar sesuai dengan tema. Syukurnya gambar-gambar yang gue punya warnanya sesuai dengan template. Jadi ga perlu tambah ribet. Walau jadinya ga terlalu fancy, tapi dengan template dan domain yang gratis sudah lebih dari cukup untuk keperluan sekarang. Udah pengen banget share hasil jadinya seperti apa, tapi masih harus nunggu. InsyaAllah soon to be published deh hasil ngulik-ngulik website di wix.com.

Twenty Six

Because today is my birthday, I’d like to repost a good article that really suits for me: original post with the same title on Medium by Nathan Bashaw.
==================================================================
Birthdays are when you can’t ignore the big, scary questions that usually lurk in the background.

Today I turn 26, and I’m leaving my job.

I’ve worked at General Assembly for a little over two years, and I still love it. Creating Dash was the happiest experience of my professional life. Over 250 thousand people have used it to learn how to make websites, and it’s definitely my proudest accomplishment. Not to mention, the GA team is like family to me.

So, why am I leaving? I want to take a shot at answering a question that I’ve been circling around for a long time.

I remember sitting in the library at Michigan State University one day during my Sophomore year, writing a paper for a philosophy class. I don’t know why I was thinking about this, but for some reason I couldn’t get the idea out of my head:

What if books were designed for screens?

In other words, what would it look like if, instead of creating with print in mind and exporting to an ebook (which is what authors and publishers do today) you started from scratch, and created a fundamentally new book experience that is designed for the screen, and takes advantage of everything computers can do (interactive, internet-connected, etc).

This question has nagged me for years. I tried out a few ideas in college, but didn’t have the discipline to take them very far. After I graduated I moved to Palo Alto to join a startup named Olark, then left after a couple years and started working on an interactive, online book to teach people to code. That ended up getting acquired by General Assembly and morphing into Dash.

I’ve worked on a bunch of random fun stuff along the way, most of it completely insignificant, and some of it completely blowing up, but I’ve never been able to shake the idea of creating books made of software. I find it endlessly fascinating for a couple reasons:

First, I believe that books make us better people. I believe that every human being is essentially curious, loving, and good. But we need to feed the good parts of our nature with stories and ideas to keep them healthy. Books are one of the best ways to do that.

Second, I believe Steve Jobs when he said that a computer is a “bicycle for the mind.” It’s amazing to me that nearly 2 billion people now own a internet-connected computer and carry it around in their pocket at all times, and that within our lifetime, it’s entirely reasonable that almost every human being will have one. What’s even more amazing is that the smartphone wave of the computer revolution is only a couple years old. I was in college when it got started.

And still, no one has figured out how to take the very ancient human desire of sharing stories and ideas through the written word, and combined it elegantly with the capabilities of modern software running on phones. Publishers still use a process that’s designed for paper and export ebooks to screens as an inferior by-product, neglecting any possibility of weaving the capabilities of computers into the story. It’s basically just a wall of text.

But to be fair, it’s not that unusual, if you look at history. Every new technology that can be used for storytelling is first used as a crude copy of the thing it replaces. The first movies were basically video-recorded plays, and the first tv shows were just radio shows with video. Eventually, creativity always catches up with technology. It just takes time.

So, I know this sounds super vague, but my plan is to try and create original, compelling books that are designed for your phone. I’ve already got a few awesome projects lined up. I don’t know exactly what will come of it, but my goal is to be able to work on this for a very long time, and to help create lots of new stories and ideas that matter.

Does this sound interesting to you? Here’s how you can get involved:

  • Are you willing to give feedback? I would appreciate that a lot! If so, you can sign up hereand get early access when I have stuff to show.
  • Are you interested in collaborating on this in any way? This is a great time for me to work with new people, so let’s talk! nbashaw@gmail.com
  • Are you an iOS developer? I’m learning objective-c, coming from a design / web background, but I could definitely use some technical mentorship.
  • Do you know anyone who works in publishing? Whether they’re an editor, agent, or author, I would love to chat and get feedback on this idea.

Also, I’d love to just catch up and bounce ideas around. I’m a big believer in talking with people from all backgrounds to see how they react. You learn something different from everyone. So if you want to just talk, I would love that! Even if we’ve never met.

I’m extremely grateful for the support system I have, and I know I’m not in this alone. Thank you for all your help!

Wish me luck!

Update: I fleshed out this idea a little more in a new post.