Ich entwickle ein Multilayer -Perzeptron, und ich habe die folgende Methode in der Klasse Multilayerperceptron, und ich möchte diese Methode so konfigurieren, dass sie auf einer GPU ausgeführt werden. Auch es ist es für mich erforderlich, Nvidia cuda api installiert zu lassen? < /P>
def backprop(self, x, y):
nabla_b = [np.zeros(b.shape) for b in self.biases]
nabla_w = [np.zeros(w.shape) for w in self.weights]
activation = x
activations = [x] # list to store all the activations, layer by layer
zs = [] # list to store all the z vectors, layer by layer
for b, w in zip(self.biases, self.weights):
z = np.dot(w, activation)+b
zs.append(z)
activation = self.apply_activation(z)
activations.append(activation)
delta = self.cost_function_derivative(activations[-1], y) *self.sigmoid_function_prime2(zs[-1])
nabla_b[-1] = delta
nabla_w[-1] = np.dot(delta, activations[-2].transpose())
for l in range(2, self.num_layers):
z = zs[-l]
sp = self.apply_activation_derivative(z)
delta = np.dot(self.weights[-l+1].transpose(), delta) * sp
nabla_b[-l] = delta
nabla_w[-l] = np.dot(delta, activations[-l-1].transpose())
return (nabla_b, nabla_w)
Ich entwickle ein Multilayer -Perzeptron, und ich habe die folgende Methode in der Klasse Multilayerperceptron, und [url=viewtopic.php?t=14917]ich möchte[/url] diese Methode so konfigurieren, dass sie auf einer GPU ausgeführt werden. Auch es ist es für mich erforderlich, Nvidia cuda api installiert zu lassen? < /P> [code] def backprop(self, x, y): nabla_b = [np.zeros(b.shape) for b in self.biases] nabla_w = [np.zeros(w.shape) for w in self.weights] activation = x activations = [x] # list to store all the activations, layer by layer zs = [] # list to store all the z vectors, layer by layer for b, w in zip(self.biases, self.weights): z = np.dot(w, activation)+b zs.append(z) activation = self.apply_activation(z) activations.append(activation) delta = self.cost_function_derivative(activations[-1], y) *self.sigmoid_function_prime2(zs[-1]) nabla_b[-1] = delta nabla_w[-1] = np.dot(delta, activations[-2].transpose()) for l in range(2, self.num_layers): z = zs[-l] sp = self.apply_activation_derivative(z) delta = np.dot(self.weights[-l+1].transpose(), delta) * sp nabla_b[-l] = delta nabla_w[-l] = np.dot(delta, activations[-l-1].transpose()) return (nabla_b, nabla_w) [/code]
Numba räumen viele numpy Funktionen in reinem Python und verwendet LLVM, um sie zu kompilieren, was zu einer allgemein effizienten Leistung führt. Einige Numba-Implementierungen zeigen jedoch eine...
Ich habe ein 2-D-Array und es erfordert ein Cumsum-Reihen. Aber Axis wird in Numba nicht unterstützt. Also stecke ich fest. Jede Hilfe wird geschätzt.
from numba import jit
import numpy as np...
Ich habe eine sehr grundlegende Gruppe nach Funktion, die ich in einem Cython -Objekt verwenden möchte, aber es ist etwas wie 400 -mal langsamer als eine ähnliche Funktion in Python, die von Numba...
Es gibt 20 Kontrollkästchen im Fenster des Benutzers. Im Code ist der Name Checkbox_1, CheckBox_2, ... CheckBox_20. Um alle Kontrollkästchen gleichzeitig zu aktivieren, verwende ich diesen...
Ich arbeite mit C++ und verwende Mingw als meinen Compiler. Bisher habe ich das Terminal unten in VS Code zum Kompilieren und Ausführen wie folgt verwendet:
g++ program.cpp und dann ./program.exe...