Пример #1
0
import os
import sys

import numpy as np
import tensorflow as tf
import tensors_saver

WEIGHTS_PATH = sys.argv[1]
tensors_saver.set_out_path(sys.argv[2])

BATCH = 64


def padd_ker(x0):

    res = np.zeros((63, 63, 64, 64), dtype=np.float32)
    for hIndex in range(0, 63, 2):
        for wIndex in range(0, 63, 2):
            for inCh in range(64):
                for oCh in range(64):
                    prevHIndex = (int)(hIndex - ((int)(hIndex / 2)))
                    prevWIndex = (int)(wIndex - ((int)(wIndex / 2)))
                    res[hIndex, wIndex, inCh, oCh] = x0[inCh, prevHIndex,
                                                        prevWIndex, oCh]

    return res


def im2col(y0):
    res = np.zeros((64 * 63 * 63, 5 * 5 * 3), dtype=np.float32)
    for b in range(3):
Пример #2
0
    s[0] = s[1]
    s[1] = s[2]
    s[2] = s[3]
    s[3] = s[3] ^ (s[3] >> np.uint64(19)) ^ t ^ (t >> np.uint64(8))
    return s[3]


def next_f32():
    x = np.float32(next_u64())
    div = np.float32(0xFFFFFFFFFFFFFFFF)
    return x / div


def np_f32(shape):

    res = np.empty(shape).astype(np.float32)
    res2 = res.reshape(res.size)
    for i in range(res2.size):
        res2[i] = next_f32()
    return res


import tensors_saver

if __name__ == '__main__':

    seed(234)

    tensors_saver.set_out_path('./out.npz')
    tensors_saver.add(np_f32((145, 18, 12, 34)))