tf.matmul
时显示一些错误:C:/ 761 / search-中的错误 bar / workload_management_app / Client / src / app / app.module.ts(8,9): 模块'“C:/ 761 / search- 酒吧/ workload_management_app /客户端/ node_modules / @角/本草 l / material“'没有导出成员'MdCardModule'。
C:/ 761 / search-中的错误 bar / workload_management_app / Client / src / app / app.module.ts(8,23): 模块'“C:/ 761 / search- 酒吧/ workload_management_app /客户端/ node_modules / @角/材料/材料“” 没有导出成员'MdTooltipModule'。
MdCardModule中的错误不是NgModule
C:/ 761 / search-中的错误 bar / workload_management_app / Client / src / app / app.module.ts(8,9):模块 ““C:/ 761 /搜索 - 酒吧/ workload_management_app /客户端/ node_modules / @角/材料/本草 l“'没有导出成员'MdCardModule'。
C:/ 761 / search-中的错误 bar / workload_management_app / Client / src / app / app.module.ts(8,23):模块 ““C:/ 761 /搜索 - 酒吧/ workload_management_app /客户端/ node_modules / @角/材料/马泰 al“'没有导出的成员'MdTooltipModule'。
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
# Parameters
learning_rate = 0.0001
training_epochs = 50
display_step = 5
Data_ABX3 = np.random.random((193, 8)).astype('f')
train_X = Data_ABX3[0:192, 0:6]
train_Y = Data_ABX3[0:192, [7]]
# placeholders for a tensor that will be always fed.
X = tf.placeholder('float32', shape = [None, 6])
Y = tf.placeholder('float32', shape = [None, 1])
# Training Data
n_samples = train_Y.shape[0]
# Set model weights
W = tf.cast(tf.Variable(np.random.randn(6, 1), name="weight"), tf.float32)
b = tf.Variable(np.random.randn(), name="bias")
mult_node = tf.matmul(X, W)
print(mult_node.shape)
# Construct a linear model
pred = tf.add(tf.matmul(X, W), b)
# Mean squared error
cost = tf.reduce_sum(tf.pow(pred-Y, 2))/(2*n_samples)
# Gradient descent
# Note, minimize() knows to modify W and b because Variable objects are trainable=True by default
optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
# Accuracy
# #accuracy = tf.contrib.metrics.streaming_accuracy(Y, pred)
# Initialize the variables (i.e. assign their default value)
init = tf.global_variables_initializer()
# Start training
with tf.Session() as sess:
# Run the initializer
sess.run(init)
# Fit all training data
for epoch in range(training_epochs):
#for (x, y) in zip(train_X, train_Y):
sess.run(optimizer, feed_dict={X: train_X, Y: train_Y})
# Display logs per epoch step
if (epoch+1) % display_step == 0:
c = sess.run(cost, feed_dict={X: train_X, Y:train_Y})
print("Epoch:", '%04d' % (epoch+1), "cost=", "{:.9f}".format(c), \
"W=", sess.run(W), "b=", sess.run(b))
print("Optimization Finished!")
#training_cost = 0
#for (x, y) in zip(train_X, train_Y):
# tr_cost = sess.run(cost, feed_dict={X: x, Y: y})
# training_cost += tr_cost
training_cost = sess.run(cost, feed_dict={X: train_X, Y: train_Y})
print("Training cost=", training_cost, "W=", sess.run(W), "b=", sess.run(b), '\n')
line = sess.run(tf.add(tf.matmul(train_X, W), b))
# Graphic display
plt.plot(train_Y, line, label='Fitted line')
plt.legend()
plt.show()`
PS:我之前试图运行
ng build
,但它没有用。
答案 0 :(得分:6)
原因是您使用的是MdCardModule
,但MatCardModule
以后应该是Md
。将所有导入的模块的Mat
更改为Md
。这很令人困惑,因为它几乎在3周前被更改了,但即使material 2.0.0-beta.11仍使用不再有效的INDIRECT()
样式。
来自beta.11更改日志:
对于beta.11,我们已决定完全弃用“md”前缀并使用“mat”向前移动。这会影响所有类名,属性,输入,输出和选择器(CSS类在2月份已更改)。 “md”前缀将在下一个测试版中删除。
答案 1 :(得分:1)
问题在于您的角度版本。将角度版本更新为4.4.3
或更高版本。材料2.0.0-beta.11
取决于4.4.3
或更高。来自[ CHANGELOG ] [1]文档:
突破变化 Angular Material现在需要Angular 4.4.3或更高版本
答案 2 :(得分:0)
您必须导入要使用的每个材质组件如果您使用的是角度cli,那么您可以在app.module.ts中全局导入它们,例如
import { MdCardModule, MdTooltipModule} from '@angular/material';
imports: [MdCardModule, MdTooltipModule]
答案 3 :(得分:0)
从角度材料更改日志:
Deprecation of "md" prefix.
In earlier betas, we've had a compatibility mode that allowed people to use either "md" or "mat" as the selector for Angular Material components. This was created so that these components could live side-by-side with AngularJS Material without CSS from the two libraries colliding.
For beta.11, we've made the decision to deprecate the "md" prefix completely and use "mat" moving forward. This affects all class names, properties, inputs, outputs, and selectors (CSS classes were changed back in February). The "md" prefixes will be removed in the next beta release.
You can automatically update your projects with the angular-material-prefix-updater tool. Check out the tool's page for instructions on how to run.
好消息是从beta 11到beta 12有migration tool:
尝试过它并且工作正常。