<commit_before>#!/usr/bin/env python

from __future__ import print_function
import argparse
import os
import os.path as osp
import shlex
import subprocess
import sys

import caffe
import chainer.functions as F
import chainer.serializers as S

import fcn
from fcn.models import FCN8s


def main():
    chainermodel = osp.join(fcn.data_dir, 'fcn8s.chainermodel')
    md5 = '4780397b1e1f2ceb98bfa6b03b18dfea'
    print("Checking md5: '{0}' for '{1}'".format(md5, chainermodel))
    if osp.exists(chainermodel) and fcn.util.check_md5(chainermodel, md5):
        print("'{0}' is already newest version.".format(chainermodel))
        sys.exit(0)

    caffemodel_dir = osp.join(fcn.data_dir, 'fcn.berkeleyvision.org/voc-fcn8s')
    caffemodel = osp.join(caffemodel_dir, 'fcn8s-heavy-pascal.caffemodel')
    caffe_prototxt = osp.join(caffemodel_dir, 'deploy.prototxt')
    if not os.path.exists(caffemodel):
        msg = "WARNING: Caffemodel '{0}' not found. Downloading..."
        print(msg, file=sys.stderr)
        url_file = osp.join(caffemodel_dir, 'caffemodel-url')
        url = open(url_file).read().strip()
        cmd = "wget '{0}' -O {1}".format(url, caffemodel)
        subprocess.check_call(shlex.split(cmd))
    net = caffe.Net(caffe_prototxt, caffemodel, caffe.TEST)

    model = FCN8s()
    for name, param in net.params.iteritems():
        layer = getattr(model, name)

        has_bias = True
        if len(param) == 1:
            has_bias = False

        print('{0}:'.format(name))
        # weight
        print('  - W:', param[0].data.shape, layer.W.data.shape)<commit_msg>Fix error printing in caffe_to_chainermodel.py<commit_after>#!/usr/bin/env python

from __future__ import print_function
import argparse
import os
import os.path as osp
import shlex
import subprocess
import sys

import caffe
import chainer.functions as F
import chainer.serializers as S

import fcn
from fcn.models import FCN8s


def main():
    chainermodel = osp.join(fcn.data_dir, 'fcn8s.chainermodel')
    md5 = '4780397b1e1f2ceb98bfa6b03b18dfea'
    print("Checking md5: '{0}' for '{1}'".format(md5, chainermodel))
    if osp.exists(chainermodel) and fcn.util.check_md5(chainermodel, md5):
        print("'{0}' is already newest version.".format(chainermodel))
        sys.exit(0)

    caffemodel_dir = osp.join(fcn.data_dir, 'fcn.berkeleyvision.org/voc-fcn8s')
    caffemodel = osp.join(caffemodel_dir, 'fcn8s-heavy-pascal.caffemodel')
    caffe_prototxt = osp.join(caffemodel_dir, 'deploy.prototxt')
    if not os.path.exists(caffemodel):
        msg = "WARNING: Caffemodel '{0}' not found. Downloading...".format(
            caffemodel)
        print(msg, file=sys.stderr)
        url_file = osp.join(caffemodel_dir, 'caffemodel-url')
        url = open(url_file).read().strip()
        cmd = "wget '{0}' -O {1}".format(url, caffemodel)
        subprocess.check_call(shlex.split(cmd))
    net = caffe.Net(caffe_prototxt, caffemodel, caffe.TEST)

    model = FCN8s()
    for name, param in net.params.iteritems():
        layer = getattr(model, name)

        has_bias = True
        if len(param) == 1:
            has_bias = False

        print('{0}:'.format(name))
        # weight
        print('  - W:', param[0].data.shape, layer.W.data.shape)
{'fraction_non_alphanumeric': 0.13042140879729314, 'fraction_numerical': 0.022762227007074746, 'mean_word_length': 3.2902374670184695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3081903', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1197, 'n_words': 244}