这是我所做的。我得到了狗/猫图像分类的代码,我编译并运行并获得了 80% 的准确率。我在 train 和 validation 文件夹中又添加了一个类(飞机)文件夹。在以下代码中进行了更改
model.compile(loss='categorical_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])
train_generator = train_datagen.flow_from_directory(
train_data_dir,
target_size=(img_width, img_height),
batch_size=batch_size,
class_mode='categorical')
validation_generator = test_datagen.flow_from_directory(
validation_data_dir,
target_size=(img_width, img_height),
batch_size=batch_size,
class_mode='categorical')
Run Code Online (Sandbox Code Playgroud)
更改binary class_mode为categorical并且也损失为categorical_crossentropy。还将输出布局更改sigmoid为softmax. 收到以下错误。
ValueError: Error when checking target: expected activation_10 to have shape (None, 1) but got array with shape (16, 3)
Run Code Online (Sandbox Code Playgroud)
我是否需要明确地将训练标签更改为如下所述的分类标签?(我使用 keras从站点多标签分类中读取了此内容)
train_labels = to_categorical(train_labels, num_classes=num_classes)
Run Code Online (Sandbox Code Playgroud)
我不确定这里会发生什么。请帮忙。我对深度学习比较陌生。
模型
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=input_shape))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2))) …Run Code Online (Sandbox Code Playgroud) python machine-learning deep-learning conv-neural-network keras
下面是我的 nginx 配置。我修改了“默认”文件(位于“可用站点”)。当通过“http”时我能够访问该网站。但是当我尝试通过“https”时,连接超时并且无法访问该页面。奇怪的是,Nginx 没有在日志中记录任何条目(access.log 和 error.log)。我正在寻求帮助,因为我对此完全陌生。
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80;
listen [::]:80;
root /var/www/main.x.com/html;
index index.html
server_name main.x.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
server {
listen 443 ssl;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/letsencrypt/live/main.x.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/main.x.com/privkey.pem;
server_name main.x.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location …Run Code Online (Sandbox Code Playgroud) 我可以编写一个def函数来完成此任务。但是,我想知道是否有任何方法可以像下面这样在一行中执行此任务string.replace('a',' ')
input = "This is a regular text"
output = "This is_a regular_text"
Run Code Online (Sandbox Code Playgroud) gnew = ggplot(data= got, aes(x= got$attacker_king, fill= got$attacker_outcome))+
geom_bar() +
geom_text(stat = "count", aes(label =..count..), vjust = -.5)+
scale_y_continuous(limits = c(0,20)) # plotting the stacked ggplot #this works
Run Code Online (Sandbox Code Playgroud)
got = ddply(got, .(got$attacker_king),
transform, pos = cumsum(..count..)- (0.5 *..count..)) # positioning labels shows error
#This shows error as "Error in eval(expr, envir, enclos) : object '..count..' not found"
Please help!
Run Code Online (Sandbox Code Playgroud)