Converting Keras 1D Convulution to PyTorch

By Henry Leung 10 Oct 2023

Recently I need to convert a model including 1D convolution layers trained with Keras v2 to PyTorch. Since Keras uses channels last $(N, L, C)$ and PyTorch uses channels first $(N, C, L)$, the weight matrix needs to be transposed in a consistent way such that the output of the two models are the same after flattening.

We can do a simple test to make sure we know how to transpose the weight matrix. Here we will create a simple model in Keras and PyTorch first and get the weight matrix from the Keras model and transpose it to PyTorch format,

Blogging with Hugo

By Henry Leung 01 Jan 2023

Introduction

I was looking into how blogging is done with Github Page with Jekyll and come across a nice one developed by https://gaohaoyang.github.io/ which this blog is based on. While making new post which is written in markdown is straight-forward, local development such as testing after you modified the code is not easy. Mainly due to Jekyll requires Ruby which requires MSYS2 which personally dislike.

So I use Windows Subsystem for Linux (WSL) which is already installed on my Windows to do the job. Just follow https://jekyllrb.com/docs/installation/ubuntu/ to install Jekyll on your WSL. Create a file called blog.sh and edit it by

Blogging with Jekyll and Developing it on Windows

By Henry Leung 10 Oct 2019

Introduction

I was looking into how blogging is done with Github Page with Jekyll and come across a nice one developed by https://gaohaoyang.github.io/ which this blog is based on. While making new post which is written in markdown is straight-forward, local development such as testing after you modified the code is not easy. Mainly due to Jekyll requires Ruby which requires MSYS2 which personally dislike.

So I use Windows Subsystem for Linux (WSL) which is already installed on my Windows to do the job. Just follow https://jekyllrb.com/docs/installation/ubuntu/ to install Jekyll on your WSL. Create a file called blog.sh and edit it by

You're up and running!

By Henry Leung 03 Mar 2014

test

testing testing

Next you can update your site name, avatar and other options using the _config.yml file in the root of your repository (shown below).

![_config.yml]({{ site.baseurl }}/images/config.png)

The easiest way to make your first post is to edit this one. Go into /_posts/ and update the Hello World markdown file. For more instructions head over to the Jekyll Now repository on GitHub.