小编Rud*_*udy的帖子

Tensorflow错误:"标签ID必须<n_classes",但我的标签ID似乎已满足此要求

我正在尝试创建一个Python 3程序,使用Tensorflow将句子分类.但是,当我尝试运行代码时,我遇到了一系列非常长的错误.以下错误似乎是我的问题的基础:

InvalidArgumentError:断言失败:[标签ID必须<n_classes] [条件x <y不按元素持有:x(线性/头部/ ToFloat:0)=] [[4] [4] 1 ...] [y (linear/head/assert_range/Const:0)=] 2

我正在使用Scikit-Learn的LabelEncoder()方法来创建标签ID,这应该符合这个要求; 他们的文档页面说:" 编码值0和之间的标签n_classes-1. "

我试图运行的代码是:

import tensorflow as tf
import pandas as pd
from sklearn import preprocessing
from sklearn.model_selection import train_test_split


data_df = pd.read_csv('data.csv') #data.csv has 2 columns: "Category", and "Description"

features = data_df.drop('Category', axis=1) #drop Category column
lab_enc = preprocessing.LabelEncoder()
labels = lab_enc.fit_transform(data_df['Category']) #Encode labels with value between 0 and n_classes-1
labels = pd.Series(labels) #pandas_input_func needs the …
Run Code Online (Sandbox Code Playgroud)

python machine-learning pandas scikit-learn tensorflow

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

mxGraph - 在 ReactJS 应用程序中某些形状无法正确呈现

我正在创建一个 React 组件,它将通过使用带有 mxGraph 的 XML 字符串来呈现图形。图形在组件内部渲染,但一些形状,如圆形、菱形和泳道,渲染不正确;它们显示为简单的正方形或矩形。这特别奇怪,因为一些非矩形形状(例如文档)正确显示。

该图是使用jgraph 的“grapheditor”工具的编辑版本创建的,其中包含一些自定义形状:

自定义图形编辑器工具

此图形编辑器工具与参考实现相同,只是更改了 addGeneralPalette() 函数Sidebar.js以使用我们自定义的形状:

/**
 * Adds the general palette to the sidebar.
 */
Sidebar.prototype.addGeneralPalette = function(expand)
{
    var fns = [
        this.createVertexTemplateEntry('ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontFamily=Helvetica;fontSize=16;fillColor=#e8f5e9;strokeColor=#4caf50;strokeWidth=4;gradientColor=#c8e6c9;', 80, 80, 'Start', 'Start', null, null, 'start begin starting beginning'),
        this.createVertexTemplateEntry('shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;strokeColor=#ff9800;strokeWidth=4;perimeterSpacing=0;fontSize=16;gradientColor=#ffe0b2;fillColor=#fff3e0;', 200, 120, 'Process', 'Process', null, null, 'process proc'),
        this.createVertexTemplateEntry('rounded=1;whiteSpace=wrap;html=1;strokeColor=#00ACC1;strokeWidth=5;glass=0;comic=0;gradientColor=#b2ebf2;fillColor=#e0f7fa;fontSize=16;fontColor=#000000;', 200, 120, 'Template', 'Template', null, null, 'template temp'),
        this.createVertexTemplateEntry('rhombus;whiteSpace=wrap;html=1;rounded=0;glass=0;comic=0;labelBackgroundColor=none;strokeColor=#333333;strokeWidth=4;fillColor=#eeeeee;gradientColor=#e5e5e5;fontFamily=Helvetica;fontSize=16;fontColor=#000000;align=center;', 200, 120, 'Decision', 'Decision', null, null, 'decision decide'),
        this.createVertexTemplateEntry('shape=document;whiteSpace=wrap;html=1;boundedLbl=1;strokeWidth=4;strokeColor=#9C27B0;gradientColor=#E1BEE7;fillColor=#F3E5F5;fontSize=16;', 200, 120, 'Documentation', 'Documentation', null, …
Run Code Online (Sandbox Code Playgroud)

javascript mxgraph jgraph reactjs

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

使用 OrientJS 模块连接到 NodeJS 中的 OrientDB --“Socket Closed”错误

我正在使用 OrientJS (v2.2.10) 在 NodeJS (v8.11.3) 中开发一个应用程序,该应用程序将连接到本地托管的 OrientDB (v3.0.6) 数据库并对其进行查询。但是,当我尝试运行程序时,每次都会收到“套接字已关闭”错误。

我能够连接到数据库并通过 OrientDB 的控制台和 Web 界面进行查询,因此我知道可以通过地址http://localhost:2480访问该数据库。如果我在命令提示符中运行“netstat -a”,我可以看到端口 2480 正在侦听 TCP 连接。

这是我当前正在运行的代码:

//Import OrientJS driver for OrientDB
var OrientJs = require('orientjs');

//Connect to OrientDB server
var server = OrientJs({
    host: "localhost",
    port: "2480",
    username: "root",
    password: "root"
});

//Connect to 'demodb'
var db = server.use({
    name: 'demodb',
    username: 'root',
    password: 'root'
});

console.log("Connected to database")

//Select all entries in 'Castles' table and print to console
db.select().from('Castles').all()
.then(function(result) {
  console.log(result); …
Run Code Online (Sandbox Code Playgroud)

database sockets node.js orientdb orientjs

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