Cublas 할때 GRU 시작 부분
2017-02-09 22:02:14

/**

* vec *= mat

* 3 times

* ex) ei_vec *= weight.transpose();

*/

cublasSgemv(handle, CUBLAS_OP_T, //cublasHandle_t handle, cublasOperation_t trans,

SIZE, SIZE, //int m, int n,

&one, //const float *alpha,

cu_reset_in_mat, SIZE, //const float *A(m x n), int lda,

cu_reset, 1, //const float *x, int incx,

&one, //const float *beta,

cu_reset, 1); //float *y, int incy)

cublasSgemv(handle, CUBLAS_OP_T, //cublasHandle_t handle, cublasOperation_t trans,

SIZE, SIZE, //int m, int n,

&one, //const float *alpha,

cu_update_in_mat, SIZE, //const float *A(m x n), int lda,

cu_update, 1, //const float *x, int incx,

&one, //const float *beta,

cu_update, 1); //float *y, int incy)

cublasSgemv(handle, CUBLAS_OP_T, //cublasHandle_t handle, cublasOperation_t trans,

SIZE, SIZE, //int m, int n,

&one, //const float *alpha,

cu_quasihidden_in_mat, SIZE, //const float *A(m x n), int lda,

cu_quasihidden, 1, //const float *x, int incx,

&one, //const float *beta,

cu_quasihidden, 1); //float *y, int incy)

▼ more
Binary, int 변환
2017-02-06 22:53:14

//할 때마다 헷갈리는 index 들

//기억할 건 단순히 binary 는 좌측부터 0 이고 int는 우측부터 0이다.

//for 문 방향 어디든 상관없음;; 어짜피 겹치는 곳이 있을 수가 없음;

#include <stdio.h>

inline int my_string_length(const char* c) { int i = 0; for (i = 0; c[i] != '\0'; i++); return i; }

void itob(int a){

    for (int i = sizeof(a) * 8 - 1; i >=0 ; i--) {

        if (a >> i & 1) printf("1");

        else printf("0");

    }

    printf("

");

}

int btoi(const char* binary) {

    int a = 0;

    int len = my_string_length(binary);

    if (len == 0)return 0;

    if (len == 32 && binary[0] == '1') {

        for (int i = len - 1; i >= 0; i--) {

            if (binary[i] == '0')

                a = a + (1 << (31-i));

        }

        a = -1 * a - 1;

    }

    else {

        for (int i = len - 1; i >= 0; i--)

            if (binary[i] == '1')

                a = a + (1 << (len - 1 -i));

    }

    return a;

}

unsigned int btou(const char* binary) {

    unsigned int a = 0;

    int len = my_string_length(binary);

    if (len == 0)return 0;

    for (int i = len - 1; i >= 0; i--)

        if (binary[i] == '1')

            a = a + (1u << (len - 1-i));

    return a;

}

int main() {

    //int to binary

    itob(-2147483648);

    //binary to int

    const char* binary = "101";

    printf("%d

",btoi(binary));

    printf("%u

", btou(binary));

}

▼ more
살 것들
2017-02-06 16:58:45

유니클로 ..

무선 키보드, 마우스

바디샴푸

선글라스 운전용

▼ more
명절 끝
2017-01-29 17:56:03

여건상 뭘 하려고 해도 불가능 했겠지만

의도적으로 적극적으로 연휴를 즐겼다.

조바심이 나는 것도 사실이지만

어쨌든 오늘 까지는 명절이다.

▼ more