我试图在PowerShell中运行此脚本.我已将以下脚本保存在ps.ps1桌面上.
$query = "SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 2"
Register-WMIEvent -Query $query -Action { invoke-item "C:\Program Files\abc.exe"}
Run Code Online (Sandbox Code Playgroud)
我已经制作了一个批处理脚本来运行这个PowerShell脚本
@echo off
Powershell.exe set-executionpolicy remotesigned -File C:\Users\SE\Desktop\ps.ps1
pause
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误:

我有一个多输出(200)二进制分类模型,我在keras中写道.
在这个模型中,我想添加其他指标,如ROC和AUC,但据我所知,keras没有内置的ROC和AUC指标函数.
我试图从scikit-learn导入ROC,AUC功能
from sklearn.metrics import roc_curve, auc
from keras.models import Sequential
from keras.layers import Dense
.
.
.
model.add(Dense(200, activation='relu'))
model.add(Dense(300, activation='relu'))
model.add(Dense(400, activation='relu'))
model.add(Dense(300, activation='relu'))
model.add(Dense(200,init='normal', activation='softmax')) #outputlayer
model.compile(loss='categorical_crossentropy', optimizer='adam',metrics=['accuracy','roc_curve','auc'])
Run Code Online (Sandbox Code Playgroud)
但它给出了这个错误:
例外:无效的指标:roc_curve
我应该如何添加ROC,AUC到keras?
我正在努力做转学习; 为此我想删除神经网络的最后两层并添加另外两层.这是一个示例代码,它也输出相同的错误.
from keras.models import Sequential
from keras.layers import Input,Flatten
from keras.layers.convolutional import Convolution2D, MaxPooling2D
from keras.layers.core import Dropout, Activation
from keras.layers.pooling import GlobalAveragePooling2D
from keras.models import Model
in_img = Input(shape=(3, 32, 32))
x = Convolution2D(12, 3, 3, subsample=(2, 2), border_mode='valid', name='conv1')(in_img)
x = Activation('relu', name='relu_conv1')(x)
x = MaxPooling2D(pool_size=(3, 3), strides=(2, 2), name='pool1')(x)
x = Convolution2D(3, 1, 1, border_mode='valid', name='conv2')(x)
x = Activation('relu', name='relu_conv2')(x)
x = GlobalAveragePooling2D()(x)
o = Activation('softmax', name='loss')(x)
model = Model(input=in_img, output=[o])
model.compile(loss="categorical_crossentropy", optimizer="adam")
#model.load_weights('model_weights.h5', by_name=True)
model.summary() …Run Code Online (Sandbox Code Playgroud) 我已经下载了一些数据作为sqlite数据库(data.db),我想在python中打开这个数据库,然后将其转换为pandas数据帧.
到目前为止,我已经做到了
import sqlite3
import pandas
dat = sqlite3.connect('data.db') #connected to database with out error
pandas.DataFrame.from_records(dat, index=None, exclude=None, columns=None, coerce_float=False, nrows=None)
Run Code Online (Sandbox Code Playgroud)
但它抛出这个错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 980, in from_records
coerce_float=coerce_float)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 5353, in _to_arrays
if not len(data):
TypeError: object of type 'sqlite3.Connection' has no len()
Run Code Online (Sandbox Code Playgroud)
如何将sqlite数据库转换为pandas数据帧
我有一个非常大的数据帧(DF)用约35-45列(变量)和行大于300行的一些包含NA,NaN时,天道酬勤,在单个或多个变量值-Inf和我已经使用
na.omit(df)以除去行使用NA和NaN但我无法使用na.omit函数删除具有Inf和-Inf值的行.
在搜索时,我遇到了这个线程在R中删除了带有Inf和NaN的行并使用了修改后的代码,df[is.finite(df)]但它没有删除带有Inf和-Inf的行,并且也给出了这个错误
is.finite(df)出错:未对类型'list'实现默认方法
EDITED
即使相应的一列或多列具有inf和-inf,也要删除整行
我使用此命令安装了Keras:
sudo pip install keras
Run Code Online (Sandbox Code Playgroud)
它正确安装并正常工作,直到我尝试导入应用程序模块:
from keras.applications.vgg16 import VGG16
Using Theano backend.
Couldn't import dot_parser, loading of dot files will not be possible.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named applications.vgg16
Run Code Online (Sandbox Code Playgroud)
我遇到了这个链接,建议卸载Keras并直接从GitHub安装Keras:
sudo pip install git+https://github.com/fchollet/keras.git
Run Code Online (Sandbox Code Playgroud)
在从GitHub重新安装Keras之前,我试图使用此命令取消对Keras的解除,但它会抛出此错误:
sudo pip uninstall keras
Can't uninstall 'Keras'. No files were found to uninstall.
Run Code Online (Sandbox Code Playgroud) 我有一个顺序学习模型的序列,它工作正常,能够预测一些输出.问题是我不知道如何将输出转换回文本序列.
这是我的代码.
from keras.preprocessing.text import Tokenizer,base_filter
from keras.preprocessing.sequence import pad_sequences
from keras.models import Sequential
from keras.layers import Dense
txt1="""What makes this problem difficult is that the sequences can vary in length,
be comprised of a very large vocabulary of input symbols and may require the model
to learn the long term context or dependencies between symbols in the input sequence."""
#txt1 is used for fitting
tk = Tokenizer(nb_words=2000, filters=base_filter(), lower=True, split=" ")
tk.fit_on_texts(txt1)
#convert text to sequence
t= tk.texts_to_sequences(txt1)
#padding …Run Code Online (Sandbox Code Playgroud) 我正在尝试理解注意力模型并自己构建一个。经过多次搜索,我发现了这个网站,它有一个用 keras 编码的注意力模型,而且看起来也很简单。但是当我试图在我的机器上构建相同的模型时,它给出了多个参数错误。错误是由于传入 class 的参数不匹配Attention。在网站的注意力类中,它要求一个参数,但它用两个参数启动注意力对象。
import tensorflow as tf
max_len = 200
rnn_cell_size = 128
vocab_size=250
class Attention(tf.keras.Model):
def __init__(self, units):
super(Attention, self).__init__()
self.W1 = tf.keras.layers.Dense(units)
self.W2 = tf.keras.layers.Dense(units)
self.V = tf.keras.layers.Dense(1)
def call(self, features, hidden):
hidden_with_time_axis = tf.expand_dims(hidden, 1)
score = tf.nn.tanh(self.W1(features) + self.W2(hidden_with_time_axis))
attention_weights = tf.nn.softmax(self.V(score), axis=1)
context_vector = attention_weights * features
context_vector = tf.reduce_sum(context_vector, axis=1)
return context_vector, attention_weights
sequence_input = tf.keras.layers.Input(shape=(max_len,), dtype='int32')
embedded_sequences = tf.keras.layers.Embedding(vocab_size, 128, input_length=max_len)(sequence_input)
lstm = tf.keras.layers.Bidirectional(tf.keras.layers.LSTM
(rnn_cell_size,
dropout=0.3,
return_sequences=True, …Run Code Online (Sandbox Code Playgroud) 是否有可能使用c程序找到函数的导数.我正在使用matlab,它有一个内置函数diff(),可用于查找函数的导数.
f(x)=x^2
Run Code Online (Sandbox Code Playgroud)
是否有可能使用c找到上述函数的导数.算法是什么?
是否可以使用类似于Google搜索的自动完整字符串和闪亮文本框中的堆栈溢出标记选择来选择多个值.
dataset<-cbind("John Doe","Ash","Ajay sharma","Ken Chong","Will Smith","Neo"....etc)
Run Code Online (Sandbox Code Playgroud)
我想从上面的数据集中选择多个变量作为我的文本框中的自动填充并将其传递给我的server.R
ui.R
shinyUI(fluidPage(
titlePanel("test"),
sidebarLayout(
sidebarPanel(
helpText("text"),
textInput("txt","Enter the text",""),
#Pass the dataset here for auto complete
),
mainPanel(
tabsetPanel(type="tab",tabPanel("Summary"),textOutput("text2"))
)
)
))
Run Code Online (Sandbox Code Playgroud)
server.R
# server.R
shinyServer(function(input, output) {
output$text2<- renderText({
paste("hello",input$txt)
})
}
)
Run Code Online (Sandbox Code Playgroud)
EDITED
我已经使用shinysky的select2input来选择多个变量,但现在我已经添加了提交按钮来一起获取所选值.
#ui.R
select2Input("txt","This is a multiple select2Input",choices=c("a","b","c"),selected=c("")),
actionButton("go","submit")
Run Code Online (Sandbox Code Playgroud)
我想绑定选定的选项让我们说用户选择a和c然后新的变量是
#server.R
input$go #if pressed submit button
var<-cbind("a","c")
output$text<-renderText({ print ("var")})
Run Code Online (Sandbox Code Playgroud)
但这不起作用
python ×6
keras ×5
theano ×3
dataframe ×2
keras-layer ×2
r ×2
autocomplete ×1
batch-file ×1
c ×1
database ×1
derivative ×1
pandas ×1
powershell ×1
shell ×1
shiny ×1
sqlite ×1
tensorflow ×1
textbox ×1
windows ×1