我正在使用以下代码在标头旁边显示# This is the for loop that I am trying to parallelize with numpy:
def get_new_weights(X, y, weight, bias, learning_rate=0.01):
weight_deriv = 0
bias_deriv = 0
total = len(X)
for i in range(total):
# -2x(y - (mx + b))
weight_deriv += -2*X[i] * (y[i] - (weight*X[i] + bias))
# -2(y - (mx + b))
bias_deriv += -2*(y[i] - (weight*X[i] + bias))
weight -= (weight_deriv / total) * learning_rate
bias -= (bias_deriv / total) * learning_rate
return weight, bias
# This is my attempt at parallelization
def update_weights(X, y, weight, bias, lr=0.01):
df_dm = np.average(-2*X * (y-(weight*X+bias))) # this was my first guess
# df_dm = np.average(np.dot((-X).T, ((weight*X+bias)-y))) # this was my second guess
df_db = np.average(-2*(y-(weight*X+bias)))
weight = weight - (lr*df_dm)
bias = bias - (lr*df_db)
return weight,bias
,但始终显示在下一行。
当前显示:-
textOutput
预期显示
GrandTotal:-
Display $ Value
这是我正在使用的代码。
GrandTotal:- Display $ Value
答案 0 :(得分:0)
将它们都包装成div
并添加block
样式,如下所示:
rm(list = ls())
library(shiny)
ui <- fluidPage(
div(style="display: inline-block;width:80px;",h3(style="color:blue;font-size:100%;","GrandTotal:-")),
div(style="display: inline-block;",textOutput("Test"))
)
server <- function(input,output) {
output$Test <- renderText("Display $ Value")
}
shinyApp(ui, server)