This file contains hidden or 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
#!/usr/bin/env python3 | |
''' | |
This will convert Keras 1 model weights and configurations | |
to their Keras 2 equivalent. Please note that all optimizer | |
configuration is ignored with this script and models will | |
need to be recompiled. | |
''' | |
import h5py |
This file contains hidden or 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 h5py | |
import shutil | |
import json | |
import sys | |
def fix_weight_file(model_path): | |
with h5py.File(model_path, "r+") as out_h5: | |
v = out_h5.attrs.get("model_config") | |
config = json.loads(v) |
This file contains hidden or 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 numpy as np | |
import matplotlib.pyplot as plt | |
import torch | |
import torch.nn as nn | |
import torch.optim as optim | |
import torch.nn.functional as F | |
from torch.autograd import Variable | |
import torchvision | |
import torchvision.transforms as transforms | |
import numpy as np |