小编A_M*_*tar的帖子

在python pandas中构造共生矩阵

我知道如何在R中这样做.但是,pandas中是否有任何函数将数据帧转换为包含两个方面共同计数的nxn共生矩阵.

例如矩阵df:

import pandas as pd

df = pd.DataFrame({'TFD' : ['AA', 'SL', 'BB', 'D0', 'Dk', 'FF'],
                    'Snack' : ['1', '0', '1', '1', '0', '0'],
                    'Trans' : ['1', '1', '1', '0', '0', '1'],
                    'Dop' : ['1', '0', '1', '0', '1', '1']}).set_index('TFD')

print df

>>> 
    Dop Snack Trans
TFD                
AA    1     1     1
SL    0     0     1
BB    1     1     1
D0    0     1     0
Dk    1     0     0
FF    1     0     1

[6 rows x 3 columns]
Run Code Online (Sandbox Code Playgroud)

会屈服:

    Dop …
Run Code Online (Sandbox Code Playgroud)

python statistics pandas

38
推荐指数
4
解决办法
3万
查看次数

CMake:无法运行MSBuild命令:MSBuild.exe

我正在尝试使用Windows 10上的GUI 构建FIATCMake.

CMake Error at CMakeLists.txt:3 (project):
  Failed to run MSBuild command:

    MSBuild.exe

  to get the value of VCTargetsPath:
Configuring incomplete, errors occurred!
Run Code Online (Sandbox Code Playgroud)

我配置CMake使用Visual Studio 15 2017编译器.

我怎样才能解决这个问题?

如果需要,这是CMakeLists.txt文件

cmake_minimum_required(VERSION 3.2)
include(CheckCXXCompilerFlag)
project(FIAT CXX)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

if(CHECK_CXX_COMPILER_USED1)
# Using Visual Studio C++
elseif("${CMAKE_CXX_COMPILER_ID}x" STREQUAL "MSVCx")
# Using Intel C++
elseif("${CMAKE_CXX_COMPILER_ID}x" STREQUAL "Intelx")
else(CHECK_CXX_COMPILER_USED1)
    # GCC or Clang
    # At least C++11
    CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
    CHECK_CXX_COMPILER_FLAG("-std=c++1z" COMPILER_SUPPORTS_CXX1Z)
    CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
    CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y)
    CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
    if(COMPILER_SUPPORTS_CXX17) …
Run Code Online (Sandbox Code Playgroud)

c++ msbuild cmake cmake-gui

28
推荐指数
6
解决办法
6万
查看次数

Keras 负载权重:OSError:无法打开文件(截断的文件:eof = 41091072)

当我尝试使用keras'加载权重时,model.load_weights I get OSError: Unable to open file (Truncated file: eof = 41091072)这是完整的错误跟踪:

model.load_weights(get_file(fname, "E:/Work/Practical\ Deep\ Learning\ Course/my\ notebooks/lesson1/vgg16.h5", cache_subdir='models'))
    141 
    142 

C:\....\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\topology.py in load_weights(self, filepath, by_name)
   2700         """
   2701         import h5py
-> 2702         f = h5py.File(filepath, mode='r')
   2703         if 'layer_names' not in f.attrs and 'model_weights' in f:
   2704             f = f['model_weights']

C:\....\Anaconda3\envs\tensorflow\lib\site-packages\h5py\_hl\files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, **kwds)
    269 
    270                 fapl = make_fapl(driver, libver, **kwds)
--> 271                 fid = make_fid(name, mode, userblock_size, …
Run Code Online (Sandbox Code Playgroud)

python h5py keras

5
推荐指数
1
解决办法
6741
查看次数

不能在上下文中使用 cuDNN 无,致命错误:cudnn.h:没有这样的文件或目录

我正在尝试配置theanogpu在我的 Windows 机器上使用。我已经设置.theanorc为使用,device= gpu但是当我运行一些应该使用 gpu 的代码时,我收到以下错误:

Can not use cuDNN on context None: cannot compile with cuDNN. We got this error:
c:\users\...\appdata\local\temp\try_flags_pt24sj.c:4:19: fatal error: cudnn.h: No such file or directory
compilation terminated.

Mapped name None to device cuda0: GeForce 840M (0000:03:00.0)
Run Code Online (Sandbox Code Playgroud)

我检查了我的CUDA_PATH=C:\Program Files\NVIDIA\v8.0GPU Computing Toolkit\CUDA 以查看 cudnn.h 是否存在,并且我在C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include

windows theano cudnn theano-cuda

5
推荐指数
1
解决办法
2786
查看次数

C++中的语义差异,定义了一个常量数据实例

在初始化常量数据成员时,以下四种不同的语法是否做同样的事情,例如,在C++ 11中是int类型?如果没有,有什么区别?

{
    const int a = 5; //usual initialization, "=" is not assignment operator here it is an initialization operator.
}
{
    const int a(5); //calling the constructor function directly
}
{
    const int a = {5}; //similar to initializing an array
}
{
    const int a{5}; //it should work, but visual studio does not recognizing it
}
Run Code Online (Sandbox Code Playgroud)

为什么第四个不被Visual Studio识别为有效语句?

c++ syntax c++11

3
推荐指数
1
解决办法
692
查看次数

尝试使用子进程将特定文件从 S3 存储桶下载到 EC2 时参数类型无效

我试图通过运行以下代码将某些文件从 S3 下载到本地计算机:

import subprocess, os
ec2_root = '/home/'
s3_root_path = "S3://bucket-name/"
s3_download_command = ["aws", "s3", "cp", os.path.join(s3_root_path, 'my_video.mp4'), os.path.join(local_root)]
p = subprocess.Popen(s3_download_command)
p.communicate()
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误: usage: aws s3 cp <LocalPath> <S3Uri> or <S3Uri> <LocalPath> or <S3Uri> <S3Uri> Error: Invalid argument type

python amazon-s3 amazon-web-services

3
推荐指数
1
解决办法
3253
查看次数

使用ffmpeg连接2个文件时,在流#1中找不到编解码器pcm_alaw的标签,容器中当前不支持编解码器

我正在尝试连接两个文件,第一个包含音频和视频,而第二个仅包含视频。我使用以下ffmpeg命令:

ffmpeg_command = ["ffmpeg", "-f", "concat", "-safe", "0", "-i", "clips_to_join.txt", "-vcodec", "copy", "-acodec", "copy", output_file_path] # output_filename = ch0X-start_time-end_time
p = subprocess.Popen(ffmpeg_command)
p.communicate()
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / …
Run Code Online (Sandbox Code Playgroud)

audio video ffmpeg codec

3
推荐指数
1
解决办法
7138
查看次数

不使用模型将两个对象从控制器传递到视图

我有一个控制器方法,我想用它来向视图发送列表和小数,而不使用模型。我怎样才能这样做呢?这是我从控制器对视图的调用:

decimal totBalance = 10.0M;
return View(query.ToList(), totBalance);
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc

2
推荐指数
1
解决办法
2845
查看次数

熊猫枢轴产生“ ValueError:索引包含重复的条目,无法重塑”

我有一个熊猫表,格式如下:

  anger_metric  metric_name angle_value
0   71.0991 roll    14.6832
1   71.0991 yaw     0.7009
2   71.0991 pitch   22.5075
3   90.1341 roll    4.8566
4   90.1341 yaw     6.4458
5   90.1341 pitch   -10.1930
Run Code Online (Sandbox Code Playgroud)

我需要为此创建一个视图,使其像这样:

  anger_metric  roll yaw pitch 
0   71.0991     14.6832 0.7009 22.5075
1   90.1341     4.8566  6.4458 -10.1930
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

df2= results.pivot(index='anger_metric', columns='metric_name', values='angle_value')
# results is the pnadas table/list
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

ValueError: Index contains duplicate entries, cannot reshape
Run Code Online (Sandbox Code Playgroud)

如何处理呢?

python pivot duplicates dataframe pandas

2
推荐指数
1
解决办法
3621
查看次数

在python中实时播放原始音频文件

我有一个udp使用python 的服务器,该服务器以原始格式(字节数组)连续接收来自客户端的语音数据包。如何在服务器端实时播放声音?有推荐的库或方法吗?

如果需要,这是我非常简单的服务器代码(我对此表示怀疑)

import socket

UDP_IP = "192.168.1.105"
UDP_PORT = 5005

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))

while True:
    data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
    #what to do to stream the incoming voice packets?
Run Code Online (Sandbox Code Playgroud)

python voice voip

1
推荐指数
1
解决办法
2434
查看次数

C++ 11-作用域和全局变量

如何从内部作用域访问全局变量,给定以下代码示例,如何从主函数和最内部作用域访问全局字符串 X,一旦我们退出它,最内部作用域也是可访问的主要范围还是其他范围?

#include <iostream>
#include <string>
std::string x = "global";
int counter = 1;

int main()
{
    std::cout <<counter ++ << " " << x << std::endl;
    std::string x = "main scope";
    std::cout <<counter ++ << " "  << x << std::endl;
    {
        std::cout <<counter ++ << " " << x << std::endl;
        std::string x = "inner scope";
        std::cout <<counter ++ << " " << x << std::endl;
    }
    std::cout <<counter++ << " "  << x << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

目前的 …

scopes c++11

0
推荐指数
1
解决办法
652
查看次数

std :: cout语句评估顺序

pop()函数有什么问题,为什么它不能正常工作?

class stack{
    int *p, *Cursor;
    int size ;
public:
    stack(int sz) {Cursor = p = new int[size=sz+1];} //consider the stack empty when its size is 1
    ~stack() {delete[] p;} //Cursor and P will be destroyed when the program finishes
    void push(int x) {Cursor+=1; *Cursor=x; size++;}
    int pop() {if(Cursor == p) return -1; int temp = *Cursor; Cursor--; size--; return (temp);}
    bool isEmpty(){return(Cursor == p);}
    bool isFull(){return(Cursor == p+size);}
};
Run Code Online (Sandbox Code Playgroud)

这是我的测试:

stack A(3);
    std::cout<<"Empty: "<<A.isEmpty()<<std::endl;
    std::cout<<"Full: "<<A.isFull()<<std::endl;
    A.push(10);
    A.push(20);
    A.push(30); …
Run Code Online (Sandbox Code Playgroud)

c++ stack

0
推荐指数
1
解决办法
409
查看次数