- 博客(19)
- 收藏
- 关注
原创 50 行 PyTorch 代码搞定 GAN
最近,一篇非常火的报道,使用pytorch 加 50 行核心代码模拟 GAN 对抗神经网络,自己尝试走了一遍,并对源码提出自己的理解。原文链接如下 https://medium.com/@devnag/generative-adversarial-networks-gans-in-50-lines-of-code-pytorch-e81b79659e3f#.nr3akui9z cod
2017-02-21 18:11:19 4231 2
原创 安装torch7 深度学习框架
在centos7 上安装torch7,首先在github上下载, git clone https://github.com/torch/distro.git ~/torch --recursive 获取安装LuaJIT(C语言编写的Lua的解释器)和Torch所必需的依赖包然后,进入torch文件夹,打开并执行install-deps中的命令,因为我之前已经在服务器上配置好了caffe
2017-02-20 16:57:59 2487
原创 python 关键字之yield、next
包含yield 关键字的函数成为一个迭代器,yield跟return的位置一样,只不过每次返回结果后,并没有退出,而是等待下一次迭代,下一次迭代开始后从yield后的语句开始执行,直到再次遇到yield,返回新一次的结果。可以看成是一个List, 但是和list的不同的是占用内存少。def subimage_generator(img, stride, patch_size, nb_hr_im
2017-02-19 00:00:01 2572
原创 python 关键字之super
class C(B): def method(self, arg): super(C, self).method(arg)子类C重写了父类B中同名方法method,在重写的实现中通过super实例化的代理对象调用父类的同名方法。举例如下class BaseSuperResolutionModel(object): def __init__(self, mod
2017-02-18 23:47:49 824
原创 Keras 切换GPU
https://keras.io/getting-started/faq/ 查看Keras 官方文档If you are running on the TensorFlow backend, your code will automatically run on GPU if any available GPU is detected.If you are running on the
2017-02-18 14:46:17 2394
原创 Swift3 基本语法
import Foundationprint("Hello, World!")var a = 5var b = 10let c = a+bprint(c,terminator:" ")var s = "hello xjc"s = "\(s) \(100)"print(s)var arr = ["hello":"xjc","he":"world"]print(arr["hell
2017-02-09 22:37:49 451
原创 数据结构之链表
#ifndef NODE_H#define NODE_Hclass Node{public: int data; Node *next; void printNode(); };#endif#include "Node.h"#include using namespace std;void Node::printNode(){ cout<<data<<endl;
2017-02-09 22:32:56 272
原创 数据结构之二叉树 使用数组实现
二叉树可以使用数组简单的实现,其原理就是左右子节点和父节点的关系, 2*index + 1 为左节点,2*index + 2 为右节点class Tree{public: Tree(int size,int *pRoot); ~ Tree(); int *SearchNode(int nodeIndex); bool AddNdode(int nodeIndex, int d
2017-02-09 22:30:45 684
原创 数据结构之二叉树
最近做leetcode 上有好多题目是关于链表和二叉树的相关操作,于是回顾了一下数据结构,实现了链表和二叉树相应的操作.#ifndef NODE_H#define NODE_Hclass Node{public: Node(); Node *SearchNode(int nodeIndex); void DeleteNode(); void PreorderTraversal
2017-02-09 22:24:55 207
原创 JNI c代码回调java空方法
首先在class JNI中定义public class JNI { static { System.loadLibrary("hello");//需要加载的so文件的名称 } //传递两个int类型的变量给C public native void callbackvoidmethod(); public void helloFromJ
2017-02-05 22:41:17 414
原创 LeetCode 155. Min Stack
解题思路:利用stack 重写 MinStack()class MinStack {public: /** initialize your data structure here. */ stackres; stackmin; void push(int x) { res.push(x); if(min.empty()
2017-02-05 13:54:17 247
原创 JNI修改Native方法数组参数中数组里面的元素值
JNIEXPORT jintArray JNICALL Java_com_example_feisou_a02_1helloworld_JNI_arrElementsIncrease (JNIEnv *env, jobject thiz, jintArray jarray){ jsize length = (*env)->GetArrayLength(env,jarray
2017-02-05 00:02:02 1098
原创 JNI开发之c代码中LOG打印调试信息
首先,在头文件中包括然后声明几个宏定义#include #define LOG_TAG "Syste.out"#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , LOG_TAG, __VA_ARGS__)#define LOGI(...) __android_log_print(ANDROID_LOG_INFO
2017-02-04 23:23:11 463
原创 LeetCode 204. Count Primes
解题思路:维基百科中 https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes Input: an integer n > 1. Let A be an array of Boolean values, indexed by integers 2 to n, initially all set to true. for i =
2017-02-03 22:05:24 251
原创 LeetCode 69. Sqrt(x)
解题思路: 牛顿迭代法, https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division点击打开链接class Solution {public: int mySqrt(int x) { long long r = x; while (r*r > x)
2017-02-03 21:34:04 343
原创 LeetCode 58. Length of Last Word
解题思路:使用 istringstreamclass Solution {public: int lengthOfLastWord(string s) { istringstream ss(s); string result; while(ss>>result){ } return result.leng
2017-02-03 21:08:51 348
原创 LeetCode 88. Merge Sorted Array
解题思路: 比较两个数组的每个数的大小,从后往前比较,大的保存在nums1的最后,遍历.class Solution {public: void merge(vector& nums1, int m, vector& nums2, int n) { while(m>0 && n>0){ if(nums2[n-1]>nums1[m-1]){
2017-02-03 20:36:05 339
原创 LeetCode 35. Search Insert Position
解题思路: 二分法class Solution {public: int searchInsert(vector& nums, int target) { int index1 = 0; int index2 = nums.size(); int mid = 0; while(index1 < index2){
2017-02-02 22:27:16 217
原创 LeetCode 206. Reverse Linked List
解题思路: 使用两个指针,分别指向head 和 head->next,或者直接递归.class Solution {public: ListNode* reverseList(ListNode* head) { ListNode* p1 = NULL; ListNode* p2 = NULL; while(head){
2017-02-02 16:06:10 169
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人