我在SO上找不到类似的问题.
如何将bash脚本作为参数正确传递给另一个bash脚本.
例如,假设我有两个脚本可以接受许多参数,我想传递一个脚本作为另一个脚本的参数.就像是:
./script1 (./script2 file1 file2) file3
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,script2将file1和file2合并在一起,并回显一个新文件,但这与该问题无关.我只是想知道如何script2
作为参数传递,即正确的语法.
如果这是不可能的,任何关于我如何规避问题的暗示都是合适的.
对于如何在考虑权重的情况下如何在Python中创建邻接矩阵,我找不到任何明确的解释。我认为创建起来应该相对简单。
我有以下矩阵...
1 2 3 4 5 6
1 0 15 0 7 10 0
2 15 0 9 11 0 9
3 0 9 0 0 12 7
4 7 11 0 0 8 14
5 10 0 12 8 0 8
6 0 9 7 14 8 0
Run Code Online (Sandbox Code Playgroud)
数字1到6是顶点,而其中的数字是每个相邻顶点之间的权重。例如,边1-2的权重为15。
我将如何在python中实现呢?我只需要一个简单的示例,而不必使用我提供的示例。
我知道如何创建邻接表...
graph = {'1': [{'2':'15'}, {'4':'7'}, {'5':'10'}],
'2': [{'3':'9'}, {'4':'11'}, {'6':'9'}],
'3': [{'5':'12'}, {'6':'7'}],
'4': [{'5':'8'}, {'6':'14'}],
'5': [{'6':'8'}]}
Run Code Online (Sandbox Code Playgroud)
但是我需要一个邻接矩阵。
以下是我AndroidManifest.xml
...
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".BeaconApp"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyBqhOHH31FYObdzoVW9TmQsv62TOP0LSLI"/>
</application>
Run Code Online (Sandbox Code Playgroud)
如您所见,我添加了获取位置信息所需的适当权限.但是,当我运行我的应用程序时,我得到一个奇怪的错误...
Looks like the app doesn't have permission to access location.
Add the following line to your app's AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
throwLocationPermissionMissing
...etc
Run Code Online (Sandbox Code Playgroud)
我已经添加了这个,AndroidManifest.xml
所以我为什么会收到这个错误.我尝试重启Android Studio.我试过从模拟器中擦除数据.我试过Gradle - > Clean.这些都没有帮助.这里发生了什么?
有可能我的Android模拟器阻止GPS或什么?
我使用tensorflow导入一些MNIST输入数据.我按照本教程... https://www.tensorflow.org/get_started/mnist/beginners
我正在导入它们......
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)
Run Code Online (Sandbox Code Playgroud)
我希望能够显示训练集中的任何图像.我知道图像的位置是mnist.train.images
,所以我尝试访问第一个图像并显示它...
with tf.Session() as sess:
#access first image
first_image = mnist.train.images[0]
first_image = np.array(first_image, dtype='uint8')
pixels = first_image.reshape((28, 28))
plt.imshow(pixels, cmap='gray')
Run Code Online (Sandbox Code Playgroud)
我试图将图像转换为28乘28的numpy数组,因为我知道每个图像是28 x 28像素.
但是,当我运行代码时,我得到的是以下内容......
显然我做错了什么.当我打印出矩阵时,一切看起来都很好,但我认为我错误地重塑了它.
我正在阅读一篇文章,解释如何欺骗神经网络来预测你想要的任何图像.我正在使用mnist
数据集.
本文提供了一个相对详细的演练,但编写它的人正在使用Caffe
.
无论如何,我的第一步是使用在mnist
数据集上训练的TensorFlow创建逻辑回归函数.所以,如果我restore
使用逻辑回归模型,我可以用它来预测任何图像.例如,我将数字7提供给以下模型......
with tf.Session() as sess:
saver.restore(sess, "/tmp/model.ckpt")
# number 7
x_in = np.expand_dims(mnist.test.images[0], axis=0)
classification = sess.run(tf.argmax(pred, 1), feed_dict={x:x_in})
print(classification)
>>>[7]
Run Code Online (Sandbox Code Playgroud)
这打印出[7]
正确的数字.
现在文章解释说,为了打破神经网络,我们需要计算神经网络的梯度.这是神经网络的衍生物.
文章指出,为了计算梯度,我们首先需要选择一个预期的结果,然后将输出概率列表设置为0,并将预期结果设置为1.反向传播是用于计算梯度的算法.
然后提供了Caffe
关于如何计算梯度的代码......
def compute_gradient(image, intended_outcome):
# Put the image into the network and make the prediction
predict(image)
# Get an empty set of probabilities
probs = np.zeros_like(net.blobs['prob'].data)
# Set the probability for our intended outcome to 1
probs[0][intended_outcome] = …
Run Code Online (Sandbox Code Playgroud) neural-network python-3.x caffe tensorflow adversarial-machines
这可能是一个非常基本的问题,但是,它似乎没有涵盖在SO上.
我最近接受了Haskell,直到现在,类型声明主要包括以下内容:
Int
Bool
Float
etc, etc
Run Code Online (Sandbox Code Playgroud)
现在我进入列表,我看到使用的类型声明a
,例如在以下函数中迭代关联列表:
contains :: Int -> [(Int,a)] -> [a]
contains x list = [values | (key,values)<-list, x==key]
Run Code Online (Sandbox Code Playgroud)
有人可以解释这a
是什么,以及它是如何工作的?从观察来看,它似乎代表了每一种类型.这是否意味着我可以输入任何类型的任何列表作为参数?
我想删除没有特定属性的第一个元素.例如,如果我的属性被定义为......
greaterOne :: Num a=>Ord a=>a->Bool
greaterOne x = x > 1
Run Code Online (Sandbox Code Playgroud)
然后功能filterFirst
应该给我这个......
filterFirst greaterOne [5,-6,-7,9,10]
>> [5,-7,9,10] //removes first element that is not greater than one
Run Code Online (Sandbox Code Playgroud)
这是我的尝试......
filterFirst :: (a->Bool)->[a]->[a]
filterFirst p [] = []
filterFirst p (x:y:xs)
|p x = filterFirst p xs
|otherwise = y:xs
Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗?
我已经坚持这个很长一段时间了,我开始认为也许反应原生地图不能在Android模拟器上工作,因为我发现似乎工作的所有答案都是针对IOS的.
我目前正在使用Android模拟器来运行我的应用程序.这是一个简单地图的代码......
class MainMap extends Component {
constructor() {
super();
}
render(){
return (
<View style={styles.container}>
<MapView
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
position: 'absolute',
top: 0,
width:150,
height:150,
left: 0,
right: 0,
bottom: 0,
},
});
module.exports = MainMap;
Run Code Online (Sandbox Code Playgroud)
代码似乎应该可以工作,因为我直接从一个例子.我甚至从谷歌API获得了我的API密钥,然后在我的中添加了以下内容AndroidManifest.xml
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="api here"/>
Run Code Online (Sandbox Code Playgroud)
现在,当我运行react-native …
我需要使用Material UI选择器在此处提供的inlineDatePicker组件:https ://material-ui-pickers.dev/getting-started/installation
我运行了npm -i
命令,但是当我尝试编译代码时,出现此错误:
Failed to compile.
./node_modules/material-ui-pickers/dist/material-ui-pickers.esm.js
577:16-26 '@material-ui/core' does not contain an export named 'makeStyles'.
Run Code Online (Sandbox Code Playgroud)
什么?我错过了什么吗?我该如何解决?
编辑:所以检查下面,我检查了版本,它给了我这个错误:
peer dep missing: @material-ui/core@^4.0.0-alpha.7, required by material-ui-pickers@3.0.0-alpha.2
Run Code Online (Sandbox Code Playgroud)
所以我做了npm -i
@ material-ui / core @ ^ 4.0.0-alpha.7
现在又出现了另一个编译错误...
'@material-ui/core' does not contain an export named 'createStyles'.
Run Code Online (Sandbox Code Playgroud)
我可以安装可以防止这种疯狂的@ material-ui / core版本吗?
我正在使用fetch
API 向我的POST
请求处理程序发送两个值...
fetch('http://localhost:8080/validation', {
method:'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email:this.state.email,
password:this.state.password
})
Run Code Online (Sandbox Code Playgroud)
我想节省email
,并password
为在服务器端的字符串。这是我的尝试...
type credentials struct {
Test string
}
func Validate(rw http.ResponseWriter, req *http.Request, _ httprouter.Params) {
decoder := json.NewDecoder(req.Body)
var creds credentials
err := decoder.Decode(&creds)
if err != nil {
panic(err)
}
fmt.Println(creds.Test)
}
Run Code Online (Sandbox Code Playgroud)
问题是我不知道发送到POST
. 我试图保存req.Body
为字符串,但这没有任何结果。
当我打印时,fmt.Println
我得到一个空格。解析它的正确方法是什么?
android ×2
google-maps ×2
haskell ×2
python ×2
react-native ×2
tensorflow ×2
bash ×1
caffe ×1
go ×1
matplotlib ×1
mnist ×1
numpy ×1
post ×1
python-3.x ×1
reactjs ×1
typescript ×1