dogs

AI:是猫还是狗,这是个问题

心已入冬 提交于 2020-03-01 09:49:18
如果你不喜欢小猫和小狗,你可能不知道他们具体是哪一种品种,但是一般来说,你都能区分出这是猫还是狗,猫和狗的特征还是不一样的,那我们如何用机器学习的方法训练一个网络区分猫狗呢? 我们选用的是 Kaggle 的一个数据集( https://www.kaggle.com/c/dogs-vs-cats/data ),用神经网络的方法进行模型的训练。下载下来的数据集对于我们测试来说数据有点大,这里面分别有 12500 个猫和狗的训练图片,我们先来缩小一下训练集,然后再进行模型的搭建和训练。我们的做法做法是猫和狗分别选择 1000 个训练图片,500 个验证集和 500 个测试集,我们可以手工完成这个工作,需要做的就是: // 如下非可执行代码,含义非常清楚的表达,最后会附上可执行代码 mkdir dog-vs-cats-small cp dog-vs-cats/train/cat/pic-{0-999}.jpg dog-vs-cats-small/train/cat/ cp dog-vs-cats/train/dog/pic-{0-999}.jpg dog-vs-cats-small/train/dog/ cp dog-vs-cats/validation/cat/pic-{1000-1499}.jpg dog-vs-cats-small/validation/cat/ cp dog-vs

谈谈.NET的协变和逆变

柔情痞子 提交于 2020-01-04 05:25:30
伴随 Visual Studio2010 的发布, C# 这门语言提供一些新的特性,包含协变( Covariant )和逆变( Contravariant )、动态( Dynamic )和 DLR 、命名参数和可选参数、索引属性、 COM 调用优化和嵌入 COM 互操作类型。写本文的目的主要是探讨下泛型类型的协变和逆变,按照以往版本 .NET 新特性的增加,一般是由新的关键字、 Attribute 来标注,继而编译器或者 .NET Runtime 负责解析执行。这两个新特性也是如此,两个关键字 in/out 。 目录 1. 协变逆变的 追本溯源 2. 协变逆变的 深入分析 3. 协变逆变的 场景应用 4. 总结 一. 追本溯源 协变和逆变需 .NET Runtime的支持,但是在以往的几个.NET 版本中,都是提供这种支持。可能大家都纳闷了,C#只是支持.NET平台的一门语言,这两者关系表明C#语言不支持,我们只有干瞪眼,还好沉寂了好几个版本之后,千呼万唤始出来。简明分析下应用场景变迁:以前都是面向对象编程,现在逐渐面向服务编程,泛型类型大量在程序设计结构中的使用,以及.NET3.0 LINQ等等应用活跃。还是举一个code场景,对于泛型接口IEnumerable<T>和IEnumerator<T>,我们经常在foreach循环进行操作,为了保证服务接口的共用性、稳定性、代码重用

keras猫狗大战

有些话、适合烂在心里 提交于 2019-12-20 09:30:29
先划分数据集程序训练集中猫狗各12500张现在提取1000张做为训练集,500张作为测试集,500张作为验证集: # -*- coding: utf-8 -*-import os, shutiloriginal_dataset_dir = '/home/duchao/projects(my)/keras/kagge/train' # 原始文解压目录base_dir = '/home/duchao/projects(my)/keras/kagge/small_data'# 创建新的文件夹os.mkdir(base_dir)# 分别对应划分好的训练(1000),验证(500)和测试目录(500)train_dir = os.path.join(base_dir, 'train')os.mkdir(train_dir)validation_dir = os.path.join(base_dir, 'validation')os.mkdir(validation_dir)test_dir = os.path.join(base_dir, 'test')os.mkdir(test_dir)# 猫的训练目录train_cats_dir = os.path.join(train_dir, 'cats')os.mkdir(train_cats_dir)# 狗的训练目录train_dogs_dir

c primer plus 专题1:初始C语言

丶灬走出姿态 提交于 2019-12-18 05:09:59
1 计算机程序执行原理: 2 C语言标准: 经典C ANSI C C99 3 程序清单1.1 C源代码示例 #include <stdio.h> int main(void) { int dogs; printf("How many dogs do you have?\n"); scanf("%d", &dogs); printf("So you have %d dog(s) !\n", dogs); (void)getchar(); return 0; } 4 微软 Visual Studio 与 C标准(给出了如何创建C工程的方法): 来源: CSDN 作者: 小小刘木子 链接: https://blog.csdn.net/dingyc_ee/article/details/103449906

Python中的静态方法?

天涯浪子 提交于 2019-12-07 10:18:30
Python中是否可以有无需初始化类即可调用的静态方法,例如: ClassName.static_method() #1楼 我认为 史蒂文实际上是对的 。 为了回答最初的问题,然后,为了建立一个类方法,只需假设第一个参数不会成为调用实例,然后确保仅从类中调用该方法。 (请注意,此答案是针对Python 3.x的。在Python 2.x中,您将在调用类本身的方法时遇到 TypeError 。) 例如: class Dog: count = 0 # this is a class variable dogs = [] # this is a class variable def __init__(self, name): self.name = name #self.name is an instance variable Dog.count += 1 Dog.dogs.append(name) def bark(self, n): # this is an instance method print("{} says: {}".format(self.name, "woof! " * n)) def rollCall(n): #this is implicitly a class method (see comments below) print("There are {} dogs

Python中的静态方法?

前提是你 提交于 2019-12-07 10:12:45
Python中是否可以有无需初始化类即可调用的静态方法,例如: ClassName.static_method() #1楼 我认为 史蒂文实际上是对的 。 为了回答最初的问题,然后,为了建立一个类方法,只需假设第一个参数不会成为调用实例,然后确保仅从类中调用该方法。 (请注意,此答案是针对Python 3.x的。在Python 2.x中,您将在调用类本身的方法时遇到 TypeError 。) 例如: class Dog: count = 0 # this is a class variable dogs = [] # this is a class variable def __init__(self, name): self.name = name #self.name is an instance variable Dog.count += 1 Dog.dogs.append(name) def bark(self, n): # this is an instance method print("{} says: {}".format(self.name, "woof! " * n)) def rollCall(n): #this is implicitly a class method (see comments below) print("There are {} dogs

Python中的静态方法?

我的梦境 提交于 2019-12-06 18:11:27
Python中是否可以有无需初始化类即可调用的静态方法,例如: ClassName.static_method() #1楼 我认为 史蒂文实际上是对的 。 为了回答最初的问题,然后,为了建立一个类方法,只需假设第一个参数不会成为调用实例,然后确保仅从类中调用该方法。 (请注意,此答案是针对Python 3.x的。在Python 2.x中,您将在调用类本身的方法时遇到 TypeError 。) 例如: class Dog: count = 0 # this is a class variable dogs = [] # this is a class variable def __init__(self, name): self.name = name #self.name is an instance variable Dog.count += 1 Dog.dogs.append(name) def bark(self, n): # this is an instance method print("{} says: {}".format(self.name, "woof! " * n)) def rollCall(n): #this is implicitly a class method (see comments below) print("There are {} dogs

python正则表达式

瘦欲@ 提交于 2019-12-05 15:10:52
一:Python 正则表达式   正则表达式(regex)是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配。   Python1.5版本起通过标准库中的re 模块来支持 Perl 风格的正则表达式。 二:正则表达模式 2.1.符号 表示法 描述 正则表达式实例 literal 匹配文本字符串的字面值literal foo re1|re2 匹配正册表达式re1或者re2 foo|bar . 匹配任何字符(除了\n之外) b.b ^ 匹配字符串起始部分 ^Dear $ 匹配字符串终止部分 /bin/*sh$ * 匹配0次或者多次前面出现的正册表达式 [A-Za-z0-9]* + 匹配1次或者多次前面出现的正册表达式 [a-z]+\.com ? 匹配0次或者1次前面出现的正册表达式 goo? {N} 匹配N次或者多次前面出现的正册表达式 [0-9]{3} {M,N} 匹配M~N次或者多次前面出现的正册表达式 [0-9]{5,9} [...] 匹配来自字符集的任意单一字符 [aeiou] [..x-y..] 匹配x~y范围中的任意单一字符 [0-9],[A-Za-z] [^...] 不匹配此字符集中中出现的任何一个字符,包括某一范围的字符(如果此字符集中出现) [^aeiou],[^A-Za-z0-9] (*|+?{})? 用于匹配上面频繁出现

How to avoid re-implementing sort.Interface for similar golang structs

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: There is one problem bothering me in Golang. Say I have 2 structs: type Dog struct { Name string Breed string Age int } type Cat struct { Name string FavoriteFood string Age int } And when I try to sort []*Dog and []*Cat by Age, I have to define 2 different sort struct like: type SortCat []*Cat func (c SortCat) Len() int {//..} func (c SortCat) Swap(i, j int) {//..} func (c SortCat) Less(i, j int) bool {//..} type SortDog []*Dog func (c SortDog) Len() int {//..} func (c SortDog) Swap(i, j int) {//..} func (c SortDog) Less(i, j int) bool {//.

Call a Server-side Method on a Resource in a RESTful Way

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Keep in mind I have a rudimentary understanding of REST. Let's say I have this URL: http://api.animals.com/v1/dogs/1/ And now, I want to make the server make the dog bark. Only the server knows how to do this. Let's say I want to have it run on a CRON job that makes the dog bark every 10 minutes for the rest of eternity. What does that call look like? I kind of want to do this: URL request: ACTION http://api.animals.com/v1/dogs/1/ In the request body: {"action":"bark"} Before you get mad at me for making up my own HTTP method, help me out